mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-02-02 21:51:01 -05:00
Merge branch 'bw/reduce-complexity' of https://github.com/Br3nda/growstuff into Br3nda-bw/reduce-complexity
This commit is contained in:
12
.rubocop.yml
12
.rubocop.yml
@@ -45,4 +45,14 @@ Metrics/LineLength:
|
||||
|
||||
# Offense count: 8
|
||||
Metrics/PerceivedComplexity:
|
||||
Max: 12
|
||||
Max: 10
|
||||
|
||||
# See https://github.com/bbatsov/rubocop/issues/3629
|
||||
Rails/HttpPositionalArguments:
|
||||
Enabled: false
|
||||
|
||||
Style/Documentation:
|
||||
Enabled: false
|
||||
|
||||
Style/FrozenStringLiteralComment:
|
||||
Enabled: false
|
||||
|
||||
@@ -38,7 +38,6 @@ Lint/AssignmentInCondition:
|
||||
# SupportedStyles: either, start_of_block, start_of_line
|
||||
Lint/BlockAlignment:
|
||||
Exclude:
|
||||
- 'spec/controllers/photos_controller_spec.rb'
|
||||
- 'spec/features/signin_spec.rb'
|
||||
- 'spec/models/seed_spec.rb'
|
||||
|
||||
@@ -162,7 +161,6 @@ Rails/ActionFilter:
|
||||
- 'app/controllers/notifications_controller.rb'
|
||||
- 'app/controllers/order_items_controller.rb'
|
||||
- 'app/controllers/orders_controller.rb'
|
||||
- 'app/controllers/photos_controller.rb'
|
||||
- 'app/controllers/plantings_controller.rb'
|
||||
- 'app/controllers/posts_controller.rb'
|
||||
- 'app/controllers/products_controller.rb'
|
||||
@@ -195,7 +193,6 @@ Rails/DynamicFindBy:
|
||||
- 'app/controllers/gardens_controller.rb'
|
||||
- 'app/controllers/harvests_controller.rb'
|
||||
- 'app/controllers/notifications_controller.rb'
|
||||
- 'app/controllers/photos_controller.rb'
|
||||
- 'app/controllers/plantings_controller.rb'
|
||||
- 'app/controllers/posts_controller.rb'
|
||||
- 'app/controllers/scientific_names_controller.rb'
|
||||
@@ -247,7 +244,6 @@ Rails/HttpPositionalArguments:
|
||||
- 'spec/controllers/notifications_controller_spec.rb'
|
||||
- 'spec/controllers/order_items_controller_spec.rb'
|
||||
- 'spec/controllers/orders_controller_spec.rb'
|
||||
- 'spec/controllers/photos_controller_spec.rb'
|
||||
- 'spec/controllers/places_controller_spec.rb'
|
||||
- 'spec/controllers/plantings_controller_spec.rb'
|
||||
- 'spec/controllers/posts_controller_spec.rb'
|
||||
@@ -335,7 +331,6 @@ Style/AlignHash:
|
||||
- 'app/models/planting.rb'
|
||||
- 'app/models/seed.rb'
|
||||
- 'db/migrate/20150201052245_create_cms.rb'
|
||||
- 'spec/controllers/photos_controller_spec.rb'
|
||||
- 'spec/models/harvest_spec.rb'
|
||||
- 'spec/models/post_spec.rb'
|
||||
- 'spec/views/notifications/index.html.haml_spec.rb'
|
||||
@@ -354,7 +349,6 @@ Style/AlignParameters:
|
||||
- 'app/controllers/comments_controller.rb'
|
||||
- 'app/controllers/gardens_controller.rb'
|
||||
- 'app/controllers/harvests_controller.rb'
|
||||
- 'app/controllers/photos_controller.rb'
|
||||
- 'app/controllers/plantings_controller.rb'
|
||||
- 'app/controllers/products_controller.rb'
|
||||
- 'app/helpers/application_helper.rb'
|
||||
@@ -451,7 +445,6 @@ Style/BlockDelimiters:
|
||||
- 'app/controllers/scientific_names_controller.rb'
|
||||
- 'spec/controllers/harvests_controller_spec.rb'
|
||||
- 'spec/controllers/order_items_controller_spec.rb'
|
||||
- 'spec/controllers/photos_controller_spec.rb'
|
||||
- 'spec/features/notifications_spec.rb'
|
||||
- 'spec/models/ability_spec.rb'
|
||||
- 'spec/models/comment_spec.rb'
|
||||
@@ -492,7 +485,6 @@ Style/BracesAroundHashParameters:
|
||||
- 'spec/controllers/notifications_controller_spec.rb'
|
||||
- 'spec/controllers/order_items_controller_spec.rb'
|
||||
- 'spec/controllers/orders_controller_spec.rb'
|
||||
- 'spec/controllers/photos_controller_spec.rb'
|
||||
- 'spec/controllers/places_controller_spec.rb'
|
||||
- 'spec/controllers/plantings_controller_spec.rb'
|
||||
- 'spec/controllers/posts_controller_spec.rb'
|
||||
@@ -508,7 +500,6 @@ Style/BracesAroundHashParameters:
|
||||
# SupportedStyles: case, end
|
||||
Style/CaseIndentation:
|
||||
Exclude:
|
||||
- 'app/controllers/photos_controller.rb'
|
||||
- 'app/helpers/application_helper.rb'
|
||||
- 'app/models/order.rb'
|
||||
- 'db/migrate/20150201052245_create_cms.rb'
|
||||
@@ -834,7 +825,6 @@ Style/ElseAlignment:
|
||||
# SupportedStyles: empty, nil, both
|
||||
Style/EmptyElse:
|
||||
Exclude:
|
||||
- 'app/controllers/photos_controller.rb'
|
||||
|
||||
# Offense count: 2
|
||||
# Cop supports --auto-correct.
|
||||
@@ -849,7 +839,6 @@ Style/EmptyLineBetweenDefs:
|
||||
Style/EmptyLines:
|
||||
Exclude:
|
||||
- 'app/controllers/gardens_controller.rb'
|
||||
- 'app/controllers/photos_controller.rb'
|
||||
- 'app/models/follow.rb'
|
||||
- 'app/models/member.rb'
|
||||
- 'app/models/post.rb'
|
||||
@@ -874,7 +863,6 @@ Style/EmptyLines:
|
||||
- 'spec/controllers/notifications_controller_spec.rb'
|
||||
- 'spec/controllers/order_items_controller_spec.rb'
|
||||
- 'spec/controllers/orders_controller_spec.rb'
|
||||
- 'spec/controllers/photos_controller_spec.rb'
|
||||
- 'spec/controllers/places_controller_spec.rb'
|
||||
- 'spec/controllers/plant_parts_controller_spec.rb'
|
||||
- 'spec/controllers/plantings_controller_spec.rb'
|
||||
@@ -1030,7 +1018,6 @@ Style/EmptyLinesAroundBlockBody:
|
||||
- 'spec/controllers/notifications_controller_spec.rb'
|
||||
- 'spec/controllers/order_items_controller_spec.rb'
|
||||
- 'spec/controllers/orders_controller_spec.rb'
|
||||
- 'spec/controllers/photos_controller_spec.rb'
|
||||
- 'spec/controllers/places_controller_spec.rb'
|
||||
- 'spec/controllers/plant_parts_controller_spec.rb'
|
||||
- 'spec/controllers/plantings_controller_spec.rb'
|
||||
@@ -1277,498 +1264,6 @@ Style/FormatString:
|
||||
- 'spec/helpers/application_helper_spec.rb'
|
||||
- 'spec/views/shop/index_spec.rb'
|
||||
|
||||
# Offense count: 485
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
||||
# SupportedStyles: when_needed, always
|
||||
Style/FrozenStringLiteralComment:
|
||||
Exclude:
|
||||
- 'Rakefile'
|
||||
- 'app/controllers/account_types_controller.rb'
|
||||
- 'app/controllers/accounts_controller.rb'
|
||||
- 'app/controllers/admin/orders_controller.rb'
|
||||
- 'app/controllers/admin_controller.rb'
|
||||
- 'app/controllers/alternate_names_controller.rb'
|
||||
- 'app/controllers/application_controller.rb'
|
||||
- 'app/controllers/authentications_controller.rb'
|
||||
- 'app/controllers/comments_controller.rb'
|
||||
- 'app/controllers/crops_controller.rb'
|
||||
- 'app/controllers/follows_controller.rb'
|
||||
- 'app/controllers/forums_controller.rb'
|
||||
- 'app/controllers/gardens_controller.rb'
|
||||
- 'app/controllers/harvests_controller.rb'
|
||||
- 'app/controllers/home_controller.rb'
|
||||
- 'app/controllers/members_controller.rb'
|
||||
- 'app/controllers/notifications_controller.rb'
|
||||
- 'app/controllers/omniauth_callbacks_controller.rb'
|
||||
- 'app/controllers/order_items_controller.rb'
|
||||
- 'app/controllers/orders_controller.rb'
|
||||
- 'app/controllers/pages_controller.rb'
|
||||
- 'app/controllers/passwords_controller.rb'
|
||||
- 'app/controllers/photos_controller.rb'
|
||||
- 'app/controllers/places_controller.rb'
|
||||
- 'app/controllers/plant_parts_controller.rb'
|
||||
- 'app/controllers/plantings_controller.rb'
|
||||
- 'app/controllers/posts_controller.rb'
|
||||
- 'app/controllers/products_controller.rb'
|
||||
- 'app/controllers/registrations_controller.rb'
|
||||
- 'app/controllers/robots_controller.rb'
|
||||
- 'app/controllers/roles_controller.rb'
|
||||
- 'app/controllers/scientific_names_controller.rb'
|
||||
- 'app/controllers/seeds_controller.rb'
|
||||
- 'app/controllers/sessions_controller.rb'
|
||||
- 'app/controllers/shop_controller.rb'
|
||||
- 'app/helpers/application_helper.rb'
|
||||
- 'app/helpers/auto_suggest_helper.rb'
|
||||
- 'app/helpers/crops_helper.rb'
|
||||
- 'app/helpers/gardens_helper.rb'
|
||||
- 'app/helpers/harvests_helper.rb'
|
||||
- 'app/helpers/notifications_helper.rb'
|
||||
- 'app/helpers/plantings_helper.rb'
|
||||
- 'app/helpers/seeds_helper.rb'
|
||||
- 'app/mailers/notifier.rb'
|
||||
- 'app/models/ability.rb'
|
||||
- 'app/models/account.rb'
|
||||
- 'app/models/account_type.rb'
|
||||
- 'app/models/alternate_name.rb'
|
||||
- 'app/models/authentication.rb'
|
||||
- 'app/models/comment.rb'
|
||||
- 'app/models/crop.rb'
|
||||
- 'app/models/follow.rb'
|
||||
- 'app/models/forum.rb'
|
||||
- 'app/models/garden.rb'
|
||||
- 'app/models/harvest.rb'
|
||||
- 'app/models/member.rb'
|
||||
- 'app/models/notification.rb'
|
||||
- 'app/models/order.rb'
|
||||
- 'app/models/order_item.rb'
|
||||
- 'app/models/photo.rb'
|
||||
- 'app/models/plant_part.rb'
|
||||
- 'app/models/planting.rb'
|
||||
- 'app/models/post.rb'
|
||||
- 'app/models/product.rb'
|
||||
- 'app/models/role.rb'
|
||||
- 'app/models/scientific_name.rb'
|
||||
- 'app/models/seed.rb'
|
||||
- 'app/validators/approved_validator.rb'
|
||||
- 'bin/bundle'
|
||||
- 'bin/rails'
|
||||
- 'bin/rake'
|
||||
- 'config.rb'
|
||||
- 'config.ru'
|
||||
- 'config/application.rb'
|
||||
- 'config/boot.rb'
|
||||
- 'config/compass.rb'
|
||||
- 'config/environment.rb'
|
||||
- 'config/environments/development.rb'
|
||||
- 'config/environments/production.rb'
|
||||
- 'config/environments/staging.rb'
|
||||
- 'config/environments/test.rb'
|
||||
- 'config/factory_girl.rb'
|
||||
- 'config/initializers/backtrace_silencers.rb'
|
||||
- 'config/initializers/comfortable_mexican_sofa.rb'
|
||||
- 'config/initializers/devise.rb'
|
||||
- 'config/initializers/escaped_markdown.rb'
|
||||
- 'config/initializers/friendly_id.rb'
|
||||
- 'config/initializers/geocoder.rb'
|
||||
- 'config/initializers/growstuff_markdown.rb'
|
||||
- 'config/initializers/inflections.rb'
|
||||
- 'config/initializers/mime_types.rb'
|
||||
- 'config/initializers/omniauth.rb'
|
||||
- 'config/initializers/session_store.rb'
|
||||
- 'config/initializers/sidekiq.rb'
|
||||
- 'config/initializers/time_formats.rb'
|
||||
- 'config/initializers/wrap_parameters.rb'
|
||||
- 'config/routes.rb'
|
||||
- 'config/setup_load_paths.rb'
|
||||
- 'config/unicorn.rb'
|
||||
- 'db/migrate/20120903092956_devise_create_users.rb'
|
||||
- 'db/migrate/20120903112806_add_username_to_users.rb'
|
||||
- 'db/migrate/20121001212604_create_crops.rb'
|
||||
- 'db/migrate/20121003190731_require_system_name_for_crops.rb'
|
||||
- 'db/migrate/20121027035231_add_slug_to_crops.rb'
|
||||
- 'db/migrate/20121105032913_create_gardens.rb'
|
||||
- 'db/migrate/20121106101718_add_slug_to_users.rb'
|
||||
- 'db/migrate/20121107012827_create_scientific_names.rb'
|
||||
- 'db/migrate/20121108105440_create_updates.rb'
|
||||
- 'db/migrate/20121109130033_add_creation_index_to_updates.rb'
|
||||
- 'db/migrate/20121203034745_add_tos_agreement_to_users.rb'
|
||||
- 'db/migrate/20121214224227_add_slug_to_updates.rb'
|
||||
- 'db/migrate/20121219022554_create_plantings.rb'
|
||||
- 'db/migrate/20130113045802_rename_updates_to_posts.rb'
|
||||
- 'db/migrate/20130113060852_rename_users_to_members.rb'
|
||||
- 'db/migrate/20130113081521_rename_post_member_to_author.rb'
|
||||
- 'db/migrate/20130113095802_rename_garden_member_to_owner.rb'
|
||||
- 'db/migrate/20130118031942_add_description_to_gardens.rb'
|
||||
- 'db/migrate/20130118043431_add_slug_to_plantings.rb'
|
||||
- 'db/migrate/20130206033956_create_comments.rb'
|
||||
- 'db/migrate/20130206051328_add_show_email_to_member.rb'
|
||||
- 'db/migrate/20130208034248_require_fields_for_comments.rb'
|
||||
- 'db/migrate/20130212001748_add_geo_to_members.rb'
|
||||
- 'db/migrate/20130212123628_create_notifications.rb'
|
||||
- 'db/migrate/20130213014511_create_forums.rb'
|
||||
- 'db/migrate/20130213015708_add_forum_to_posts.rb'
|
||||
- 'db/migrate/20130214024117_create_roles.rb'
|
||||
- 'db/migrate/20130214034838_add_members_roles_table.rb'
|
||||
- 'db/migrate/20130215131921_rename_notification_fields.rb'
|
||||
- 'db/migrate/20130220044605_add_slug_to_forums.rb'
|
||||
- 'db/migrate/20130220044642_add_slug_to_roles.rb'
|
||||
- 'db/migrate/20130222060730_default_read_to_false.rb'
|
||||
- 'db/migrate/20130326092227_change_planted_at_to_date.rb'
|
||||
- 'db/migrate/20130327120024_add_send_email_to_member.rb'
|
||||
- 'db/migrate/20130329045744_add_sunniness_to_planting.rb'
|
||||
- 'db/migrate/20130404174459_create_authentications.rb'
|
||||
- 'db/migrate/20130409103549_make_post_subject_non_null.rb'
|
||||
- 'db/migrate/20130409162140_add_name_to_authentications.rb'
|
||||
- 'db/migrate/20130507105357_create_products.rb'
|
||||
- 'db/migrate/20130507110411_create_orders.rb'
|
||||
- 'db/migrate/20130507113915_add_orders_products_table.rb'
|
||||
- 'db/migrate/20130508050711_add_completed_to_order.rb'
|
||||
- 'db/migrate/20130508104506_create_photos.rb'
|
||||
- 'db/migrate/20130509123711_add_metadata_to_photos.rb'
|
||||
- 'db/migrate/20130514124515_add_parent_to_crop.rb'
|
||||
- 'db/migrate/20130515033842_create_order_items.rb'
|
||||
- 'db/migrate/20130515054017_change_order_member_id_to_integer.rb'
|
||||
- 'db/migrate/20130515122301_change_prices_to_integers.rb'
|
||||
- 'db/migrate/20130517015920_create_account_details.rb'
|
||||
- 'db/migrate/20130517051922_create_account_types.rb'
|
||||
- 'db/migrate/20130517234458_require_account_type_name.rb'
|
||||
- 'db/migrate/20130518000339_add_columns_to_product.rb'
|
||||
- 'db/migrate/20130518002942_rename_account_detail_to_account.rb'
|
||||
- 'db/migrate/20130529032813_add_express_token_to_orders.rb'
|
||||
- 'db/migrate/20130531110729_add_photos_plantings_table.rb'
|
||||
- 'db/migrate/20130601011725_change_flickr_photo_id_to_string.rb'
|
||||
- 'db/migrate/20130606230333_change_product_description_to_text.rb'
|
||||
- 'db/migrate/20130606233733_add_recommended_price_to_product.rb'
|
||||
- 'db/migrate/20130705104238_add_planted_from_to_planting.rb'
|
||||
- 'db/migrate/20130715110134_create_seeds.rb'
|
||||
- 'db/migrate/20130718005600_change_use_by_to_plant_before_on_seed.rb'
|
||||
- 'db/migrate/20130718011247_add_trading_to_seeds.rb'
|
||||
- 'db/migrate/20130722050836_remove_tradable_from_seeds.rb'
|
||||
- 'db/migrate/20130723103128_set_default_tradable_to_on_seed.rb'
|
||||
- 'db/migrate/20130723110702_add_slug_to_seed.rb'
|
||||
- 'db/migrate/20130809012511_add_bio_to_members.rb'
|
||||
- 'db/migrate/20130819004549_add_planting_count_to_crop.rb'
|
||||
- 'db/migrate/20130821011352_add_creator_to_crops.rb'
|
||||
- 'db/migrate/20130821073736_add_creator_to_scientific_name.rb'
|
||||
- 'db/migrate/20130826012139_add_owner_to_planting.rb'
|
||||
- 'db/migrate/20130826023159_add_plantings_count_to_member.rb'
|
||||
- 'db/migrate/20130827105823_add_newsletter_to_member.rb'
|
||||
- 'db/migrate/20130913015118_add_referral_code_to_order.rb'
|
||||
- 'db/migrate/20130917053547_create_harvests.rb'
|
||||
- 'db/migrate/20130917060257_change_harvest_notes_to_description.rb'
|
||||
- 'db/migrate/20130917071545_change_harvest_units_to_unit.rb'
|
||||
- 'db/migrate/20130917075803_add_slug_to_harvests.rb'
|
||||
- 'db/migrate/20130925050304_add_weight_to_harvests.rb'
|
||||
- 'db/migrate/20131018101204_rename_system_name_to_name.rb'
|
||||
- 'db/migrate/20131025104228_add_fields_to_gardens.rb'
|
||||
- 'db/migrate/20131029053113_add_plant_part_to_harvests.rb'
|
||||
- 'db/migrate/20131030230908_create_plant_parts.rb'
|
||||
- 'db/migrate/20131030231202_change_plant_part_to_plant_part_id.rb'
|
||||
- 'db/migrate/20131031000655_add_slug_to_plant_part.rb'
|
||||
- 'db/migrate/20140718075753_default_plantings_count_to_zero.rb'
|
||||
- 'db/migrate/20140829230600_add_finished_to_planting.rb'
|
||||
- 'db/migrate/20140905001730_add_harvests_photos_table.rb'
|
||||
- 'db/migrate/20140928044231_add_crops_posts_table.rb'
|
||||
- 'db/migrate/20140928085713_add_send_planting_reminder_to_member.rb'
|
||||
- 'db/migrate/20141002022459_create_index_harvest_photos.rb'
|
||||
- 'db/migrate/20141018111015_create_alternate_names.rb'
|
||||
- 'db/migrate/20141111130849_create_follows.rb'
|
||||
- 'db/migrate/20141119130555_change_follows_member_id_to_follower_id.rb'
|
||||
- 'db/migrate/20150124110540_add_properties_to_seeds.rb'
|
||||
- 'db/migrate/20150127043022_add_gardens_photos_table.rb'
|
||||
- 'db/migrate/20150129034206_add_si_weight_to_harvest.rb'
|
||||
- 'db/migrate/20150130224814_add_requester_to_crops.rb'
|
||||
- 'db/migrate/20150201052245_create_cms.rb'
|
||||
- 'db/migrate/20150201053200_add_approval_status_to_crops.rb'
|
||||
- 'db/migrate/20150201062506_add_reason_for_rejection_to_crops.rb'
|
||||
- 'db/migrate/20150201064502_add_request_notes_to_crops.rb'
|
||||
- 'db/migrate/20150209105410_add_rejection_notes_to_crops.rb'
|
||||
- 'db/migrate/20150625224805_add_days_before_maturity_to_plantings.rb'
|
||||
- 'db/migrate/20150824145414_add_member_preferred_image.rb'
|
||||
- 'db/seeds.rb'
|
||||
- 'lib/actions/oauth_signup_action.rb'
|
||||
- 'lib/geocodable.rb'
|
||||
- 'lib/haml/filters/escaped_markdown.rb'
|
||||
- 'lib/haml/filters/growstuff_markdown.rb'
|
||||
- 'lib/tasks/growstuff.rake'
|
||||
- 'lib/tasks/hooks.rake'
|
||||
- 'lib/tasks/testing.rake'
|
||||
- 'script/check_contributors_md'
|
||||
- 'script/gemfile_check'
|
||||
- 'script/heroku_maintenance.rb'
|
||||
- 'script/rails'
|
||||
- 'spec/controllers/account_types_controller_spec.rb'
|
||||
- 'spec/controllers/accounts_controller_spec.rb'
|
||||
- 'spec/controllers/admin/orders_controller_spec.rb'
|
||||
- 'spec/controllers/admin_controller_spec.rb'
|
||||
- 'spec/controllers/authentications_controller_spec.rb'
|
||||
- 'spec/controllers/comments_controller_spec.rb'
|
||||
- 'spec/controllers/crops_controller_spec.rb'
|
||||
- 'spec/controllers/forums_controller_spec.rb'
|
||||
- 'spec/controllers/gardens_controller_spec.rb'
|
||||
- 'spec/controllers/harvests_controller_spec.rb'
|
||||
- 'spec/controllers/home_controller_spec.rb'
|
||||
- 'spec/controllers/member_controller_spec.rb'
|
||||
- 'spec/controllers/notifications_controller_spec.rb'
|
||||
- 'spec/controllers/order_items_controller_spec.rb'
|
||||
- 'spec/controllers/orders_controller_spec.rb'
|
||||
- 'spec/controllers/photos_controller_spec.rb'
|
||||
- 'spec/controllers/places_controller_spec.rb'
|
||||
- 'spec/controllers/plant_parts_controller_spec.rb'
|
||||
- 'spec/controllers/plantings_controller_spec.rb'
|
||||
- 'spec/controllers/posts_controller_spec.rb'
|
||||
- 'spec/controllers/products_controller_spec.rb'
|
||||
- 'spec/controllers/registrations_controller_spec.rb'
|
||||
- 'spec/controllers/robots_controller_spec.rb'
|
||||
- 'spec/controllers/roles_controller_spec.rb'
|
||||
- 'spec/controllers/scientific_names_controller_spec.rb'
|
||||
- 'spec/controllers/seeds_controller_spec.rb'
|
||||
- 'spec/controllers/shop_controller_spec.rb'
|
||||
- 'spec/custom_matchers.rb'
|
||||
- 'spec/factories/account_types.rb'
|
||||
- 'spec/factories/accounts.rb'
|
||||
- 'spec/factories/alternate_names.rb'
|
||||
- 'spec/factories/authentications.rb'
|
||||
- 'spec/factories/comments.rb'
|
||||
- 'spec/factories/crop.rb'
|
||||
- 'spec/factories/follows.rb'
|
||||
- 'spec/factories/forums.rb'
|
||||
- 'spec/factories/garden.rb'
|
||||
- 'spec/factories/harvests.rb'
|
||||
- 'spec/factories/member.rb'
|
||||
- 'spec/factories/notifications.rb'
|
||||
- 'spec/factories/order_items.rb'
|
||||
- 'spec/factories/orders.rb'
|
||||
- 'spec/factories/photos.rb'
|
||||
- 'spec/factories/plant_parts.rb'
|
||||
- 'spec/factories/planting.rb'
|
||||
- 'spec/factories/post.rb'
|
||||
- 'spec/factories/products.rb'
|
||||
- 'spec/factories/roles.rb'
|
||||
- 'spec/factories/scientific_name.rb'
|
||||
- 'spec/factories/seeds.rb'
|
||||
- 'spec/features/admin/account_types_spec.rb'
|
||||
- 'spec/features/admin/forums_spec.rb'
|
||||
- 'spec/features/admin/products_spec.rb'
|
||||
- 'spec/features/cms_spec.rb'
|
||||
- 'spec/features/comments/commenting_a_comment_spec.rb'
|
||||
- 'spec/features/crops/alternate_name_spec.rb'
|
||||
- 'spec/features/crops/browse_crops_spec.rb'
|
||||
- 'spec/features/crops/creating_a_crop_spec.rb'
|
||||
- 'spec/features/crops/crop_detail_page_spec.rb'
|
||||
- 'spec/features/crops/crop_search_spec.rb'
|
||||
- 'spec/features/crops/crop_wranglers_spec.rb'
|
||||
- 'spec/features/crops/crop_wrangling_button_spec.rb'
|
||||
- 'spec/features/crops/inflections_spec.rb'
|
||||
- 'spec/features/crops/request_new_crop_spec.rb'
|
||||
- 'spec/features/following_spec.rb'
|
||||
- 'spec/features/footer_spec.rb'
|
||||
- 'spec/features/gardens/adding_gardens_spec.rb'
|
||||
- 'spec/features/gardens_spec.rb'
|
||||
- 'spec/features/harvests/browse_harvests_spec.rb'
|
||||
- 'spec/features/harvests/harvesting_a_crop_spec.rb'
|
||||
- 'spec/features/locale_spec.rb'
|
||||
- 'spec/features/member_profile_spec.rb'
|
||||
- 'spec/features/members_list_spec.rb'
|
||||
- 'spec/features/notifications_spec.rb'
|
||||
- 'spec/features/photos/show_photo_spec.rb'
|
||||
- 'spec/features/places/searching_a_place_spec.rb'
|
||||
- 'spec/features/planting_reminder_spec.rb'
|
||||
- 'spec/features/plantings/planting_a_crop_spec.rb'
|
||||
- 'spec/features/posts/posting_a_post_spec.rb'
|
||||
- 'spec/features/rss/comments_spec.rb'
|
||||
- 'spec/features/rss/crops_spec.rb'
|
||||
- 'spec/features/rss/members_spec.rb'
|
||||
- 'spec/features/rss/plantings_spec.rb'
|
||||
- 'spec/features/rss/posts_spec.rb'
|
||||
- 'spec/features/rss/seeds_spec.rb'
|
||||
- 'spec/features/scientific_name_spec.rb'
|
||||
- 'spec/features/seeds/adding_seeds_spec.rb'
|
||||
- 'spec/features/seeds/misc_seeds_spec.rb'
|
||||
- 'spec/features/shared_examples/append_date.rb'
|
||||
- 'spec/features/shared_examples/crop_suggest.rb'
|
||||
- 'spec/features/signin_spec.rb'
|
||||
- 'spec/features/signout_spec.rb'
|
||||
- 'spec/features/signup_spec.rb'
|
||||
- 'spec/features/unsubscribing_spec.rb'
|
||||
- 'spec/helpers/application_helper_spec.rb'
|
||||
- 'spec/helpers/crops_helper_spec.rb'
|
||||
- 'spec/helpers/gardens_helper_spec.rb'
|
||||
- 'spec/helpers/harvests_helper_spec.rb'
|
||||
- 'spec/helpers/notifications_helper_spec.rb'
|
||||
- 'spec/helpers/plantings_helper_spec.rb'
|
||||
- 'spec/helpers/seeds_helper_spec.rb'
|
||||
- 'spec/lib/actions/oauth_signup_action_spec.rb'
|
||||
- 'spec/lib/haml/filters/escaped_markdown_spec.rb'
|
||||
- 'spec/lib/haml/filters/growstuff_markdown_spec.rb'
|
||||
- 'spec/mailers/notifier_spec.rb'
|
||||
- 'spec/models/ability_spec.rb'
|
||||
- 'spec/models/account_spec.rb'
|
||||
- 'spec/models/account_type_spec.rb'
|
||||
- 'spec/models/alternate_name_spec.rb'
|
||||
- 'spec/models/authentication_spec.rb'
|
||||
- 'spec/models/comment_spec.rb'
|
||||
- 'spec/models/crop_spec.rb'
|
||||
- 'spec/models/follow_spec.rb'
|
||||
- 'spec/models/forum_spec.rb'
|
||||
- 'spec/models/garden_spec.rb'
|
||||
- 'spec/models/harvest_spec.rb'
|
||||
- 'spec/models/member_spec.rb'
|
||||
- 'spec/models/notification_spec.rb'
|
||||
- 'spec/models/order_item_spec.rb'
|
||||
- 'spec/models/order_spec.rb'
|
||||
- 'spec/models/photo_spec.rb'
|
||||
- 'spec/models/plant_part_spec.rb'
|
||||
- 'spec/models/planting_spec.rb'
|
||||
- 'spec/models/post_spec.rb'
|
||||
- 'spec/models/product_spec.rb'
|
||||
- 'spec/models/role_spec.rb'
|
||||
- 'spec/models/scientific_name_spec.rb'
|
||||
- 'spec/models/seed_spec.rb'
|
||||
- 'spec/rails_helper.rb'
|
||||
- 'spec/requests/authentications_spec.rb'
|
||||
- 'spec/requests/comments_spec.rb'
|
||||
- 'spec/requests/forums_spec.rb'
|
||||
- 'spec/requests/gardens_spec.rb'
|
||||
- 'spec/requests/harvests_spec.rb'
|
||||
- 'spec/requests/notifications_spec.rb'
|
||||
- 'spec/requests/photos_spec.rb'
|
||||
- 'spec/requests/plant_parts_spec.rb'
|
||||
- 'spec/requests/plantings_spec.rb'
|
||||
- 'spec/requests/post_spec.rb'
|
||||
- 'spec/requests/scientific_names_spec.rb'
|
||||
- 'spec/requests/seeds_spec.rb'
|
||||
- 'spec/routing/account_types_routing_spec.rb'
|
||||
- 'spec/routing/authentications_routing_spec.rb'
|
||||
- 'spec/routing/comments_routing_spec.rb'
|
||||
- 'spec/routing/crops_routing_spec.rb'
|
||||
- 'spec/routing/follows_routing_spec.rb'
|
||||
- 'spec/routing/forums_routing_spec.rb'
|
||||
- 'spec/routing/gardens_routing_spec.rb'
|
||||
- 'spec/routing/harvests_routing_spec.rb'
|
||||
- 'spec/routing/notifications_routing_spec.rb'
|
||||
- 'spec/routing/order_items_routing_spec.rb'
|
||||
- 'spec/routing/orders_routing_spec.rb'
|
||||
- 'spec/routing/photos_routing_spec.rb'
|
||||
- 'spec/routing/plant_parts_routing_spec.rb'
|
||||
- 'spec/routing/plantings_routing_spec.rb'
|
||||
- 'spec/routing/products_routing_spec.rb'
|
||||
- 'spec/routing/roles_routing_spec.rb'
|
||||
- 'spec/routing/scientific_names_routing_spec.rb'
|
||||
- 'spec/routing/seeds_routing_spec.rb'
|
||||
- 'spec/routing/updates_routing_spec.rb'
|
||||
- 'spec/spec_helper.rb'
|
||||
- 'spec/support/controller_macros.rb'
|
||||
- 'spec/support/database_cleaner.rb'
|
||||
- 'spec/support/devise.rb'
|
||||
- 'spec/support/elasticsearch_helpers.rb'
|
||||
- 'spec/support/feature_helpers.rb'
|
||||
- 'spec/views/account_types/edit.html.haml_spec.rb'
|
||||
- 'spec/views/account_types/index.html.haml_spec.rb'
|
||||
- 'spec/views/account_types/new.html.haml_spec.rb'
|
||||
- 'spec/views/account_types/show.html.haml_spec.rb'
|
||||
- 'spec/views/accounts/edit.html.haml_spec.rb'
|
||||
- 'spec/views/accounts/index.html.haml_spec.rb'
|
||||
- 'spec/views/accounts/new.html.haml_spec.rb'
|
||||
- 'spec/views/accounts/show.html.haml_spec.rb'
|
||||
- 'spec/views/admin/index_spec.rb'
|
||||
- 'spec/views/admin/newsletter_spec.rb'
|
||||
- 'spec/views/admin/orders/index_spec.rb'
|
||||
- 'spec/views/comments/edit.html.haml_spec.rb'
|
||||
- 'spec/views/comments/index.html.haml_spec.rb'
|
||||
- 'spec/views/comments/index.rss.haml_spec.rb'
|
||||
- 'spec/views/comments/new.html.haml_spec.rb'
|
||||
- 'spec/views/comments/show.html.haml_spec.rb'
|
||||
- 'spec/views/crops/_grown_for.html.haml_spec.rb'
|
||||
- 'spec/views/crops/_planting_advice.html.haml_spec.rb'
|
||||
- 'spec/views/crops/_popover.html.haml_spec.rb'
|
||||
- 'spec/views/crops/edit.html.haml_spec.rb'
|
||||
- 'spec/views/crops/hierarchy.html.haml_spec.rb'
|
||||
- 'spec/views/crops/index.html.haml_spec.rb'
|
||||
- 'spec/views/crops/index.rss.haml_spec.rb'
|
||||
- 'spec/views/crops/new.html.haml_spec.rb'
|
||||
- 'spec/views/crops/wrangle.html.haml_spec.rb'
|
||||
- 'spec/views/devise/confirmations/new_spec.rb'
|
||||
- 'spec/views/devise/mailer/confirmation_instructions_spec.rb'
|
||||
- 'spec/views/devise/mailer/reset_password_instructions_spec.rb'
|
||||
- 'spec/views/devise/mailer/unlock_instructions_spec.rb'
|
||||
- 'spec/views/devise/registrations/edit_spec.rb'
|
||||
- 'spec/views/devise/registrations/new_spec.rb'
|
||||
- 'spec/views/devise/sessions/new_spec.rb'
|
||||
- 'spec/views/devise/shared/_links_spec.rb'
|
||||
- 'spec/views/devise/unlocks/new_spec.rb'
|
||||
- 'spec/views/forums/edit.html.haml_spec.rb'
|
||||
- 'spec/views/forums/index.html.haml_spec.rb'
|
||||
- 'spec/views/forums/new.html.haml_spec.rb'
|
||||
- 'spec/views/forums/show.html.haml_spec.rb'
|
||||
- 'spec/views/gardens/edit.html.haml_spec.rb'
|
||||
- 'spec/views/gardens/new.html.haml_spec.rb'
|
||||
- 'spec/views/gardens/show.html.haml_spec.rb'
|
||||
- 'spec/views/harvests/edit.html.haml_spec.rb'
|
||||
- 'spec/views/harvests/index.html.haml_spec.rb'
|
||||
- 'spec/views/harvests/new.html.haml_spec.rb'
|
||||
- 'spec/views/harvests/show.html.haml_spec.rb'
|
||||
- 'spec/views/home/_blurb.html.haml_spec.rb'
|
||||
- 'spec/views/home/_crops.html.haml_spec.rb'
|
||||
- 'spec/views/home/_members.html.haml_spec.rb'
|
||||
- 'spec/views/home/_seeds.html.haml_spec.rb'
|
||||
- 'spec/views/home/_stats.html.haml_spec.rb'
|
||||
- 'spec/views/home/index_spec.rb'
|
||||
- 'spec/views/layouts/_header_spec.rb'
|
||||
- 'spec/views/layouts/_meta_spec.rb'
|
||||
- 'spec/views/layouts/application_spec.rb'
|
||||
- 'spec/views/members/_location.html.haml_spec.rb'
|
||||
- 'spec/views/members/index.html.haml_spec.rb'
|
||||
- 'spec/views/members/show.rss.haml_spec.rb'
|
||||
- 'spec/views/notifications/index.html.haml_spec.rb'
|
||||
- 'spec/views/notifications/new.html.haml_spec.rb'
|
||||
- 'spec/views/notifications/show.html.haml_spec.rb'
|
||||
- 'spec/views/notifier/notify.html.haml_spec.rb'
|
||||
- 'spec/views/orders/index.html.haml_spec.rb'
|
||||
- 'spec/views/orders/show.html.haml_spec.rb'
|
||||
- 'spec/views/photos/edit.html.haml_spec.rb'
|
||||
- 'spec/views/photos/index.html.haml_spec.rb'
|
||||
- 'spec/views/photos/new.html.haml_spec.rb'
|
||||
- 'spec/views/photos/show.html.haml_spec.rb'
|
||||
- 'spec/views/places/_map_attribution.html.haml_spec.rb'
|
||||
- 'spec/views/places/index.html.haml_spec.rb'
|
||||
- 'spec/views/places/show.html.haml_spec.rb'
|
||||
- 'spec/views/plant_parts/edit.html.haml_spec.rb'
|
||||
- 'spec/views/plant_parts/index.html.haml_spec.rb'
|
||||
- 'spec/views/plant_parts/new.html.haml_spec.rb'
|
||||
- 'spec/views/plant_parts/show.html.haml_spec.rb'
|
||||
- 'spec/views/plantings/_form.html.haml_spec.rb'
|
||||
- 'spec/views/plantings/edit.html.haml_spec.rb'
|
||||
- 'spec/views/plantings/index.html.haml_spec.rb'
|
||||
- 'spec/views/plantings/index.rss.haml_spec.rb'
|
||||
- 'spec/views/plantings/new.html.haml_spec.rb'
|
||||
- 'spec/views/plantings/show.html.haml_spec.rb'
|
||||
- 'spec/views/posts/_single.html.haml_spec.rb'
|
||||
- 'spec/views/posts/edit.html.haml_spec.rb'
|
||||
- 'spec/views/posts/index.html.haml_spec.rb'
|
||||
- 'spec/views/posts/index.rss.haml_spec.rb'
|
||||
- 'spec/views/posts/new.html.haml_spec.rb'
|
||||
- 'spec/views/posts/show.html.haml_spec.rb'
|
||||
- 'spec/views/posts/show.rss.haml_spec.rb'
|
||||
- 'spec/views/products/edit.html.haml_spec.rb'
|
||||
- 'spec/views/products/index.html.haml_spec.rb'
|
||||
- 'spec/views/products/new.html.haml_spec.rb'
|
||||
- 'spec/views/products/show.html.haml_spec.rb'
|
||||
- 'spec/views/roles/edit.html.haml_spec.rb'
|
||||
- 'spec/views/roles/index.html.haml_spec.rb'
|
||||
- 'spec/views/roles/new.html.haml_spec.rb'
|
||||
- 'spec/views/roles/show.html.haml_spec.rb'
|
||||
- 'spec/views/scientific_names/edit.html.haml_spec.rb'
|
||||
- 'spec/views/scientific_names/index.html.haml_spec.rb'
|
||||
- 'spec/views/scientific_names/new.html.haml_spec.rb'
|
||||
- 'spec/views/scientific_names/show.html.haml_spec.rb'
|
||||
- 'spec/views/seeds/edit.html.haml_spec.rb'
|
||||
- 'spec/views/seeds/index.rss.haml_spec.rb'
|
||||
- 'spec/views/seeds/new.html.haml_spec.rb'
|
||||
- 'spec/views/seeds/show.html.haml_spec.rb'
|
||||
- 'spec/views/shop/index_spec.rb'
|
||||
|
||||
# Offense count: 35
|
||||
# Configuration parameters: MinBodyLength.
|
||||
Style/GuardClause:
|
||||
@@ -1845,7 +1340,6 @@ Style/IndentHash:
|
||||
- 'config/environments/production.rb'
|
||||
- 'config/environments/staging.rb'
|
||||
- 'config/environments/test.rb'
|
||||
- 'spec/controllers/photos_controller_spec.rb'
|
||||
- 'spec/lib/actions/oauth_signup_action_spec.rb'
|
||||
|
||||
# Offense count: 25
|
||||
@@ -1880,7 +1374,6 @@ Style/IndentationWidth:
|
||||
- 'db/migrate/20141119130555_change_follows_member_id_to_follower_id.rb'
|
||||
- 'lib/tasks/hooks.rake'
|
||||
- 'spec/controllers/harvests_controller_spec.rb'
|
||||
- 'spec/controllers/photos_controller_spec.rb'
|
||||
- 'spec/features/signin_spec.rb'
|
||||
- 'spec/lib/haml/filters/growstuff_markdown_spec.rb'
|
||||
- 'spec/models/garden_spec.rb'
|
||||
@@ -2029,7 +1522,6 @@ Style/MultilineMethodCallIndentation:
|
||||
# SupportedStyles: aligned, indented
|
||||
Style/MultilineOperationIndentation:
|
||||
Exclude:
|
||||
- 'app/controllers/photos_controller.rb'
|
||||
- 'app/controllers/registrations_controller.rb'
|
||||
|
||||
# Offense count: 2
|
||||
@@ -2159,7 +1651,6 @@ Style/PerlBackrefs:
|
||||
Style/PredicateName:
|
||||
Exclude:
|
||||
- 'spec/**/*'
|
||||
- 'app/controllers/photos_controller.rb'
|
||||
- 'app/models/member.rb'
|
||||
|
||||
# Offense count: 1
|
||||
@@ -2368,7 +1859,6 @@ Style/SpaceInsideHashLiteralBraces:
|
||||
- 'spec/controllers/notifications_controller_spec.rb'
|
||||
- 'spec/controllers/order_items_controller_spec.rb'
|
||||
- 'spec/controllers/orders_controller_spec.rb'
|
||||
- 'spec/controllers/photos_controller_spec.rb'
|
||||
- 'spec/controllers/plantings_controller_spec.rb'
|
||||
- 'spec/controllers/seeds_controller_spec.rb'
|
||||
- 'spec/views/notifications/show.html.haml_spec.rb'
|
||||
@@ -2382,7 +1872,6 @@ Style/SpaceInsideParens:
|
||||
Exclude:
|
||||
- 'app/models/crop.rb'
|
||||
- 'config/environments/test.rb'
|
||||
- 'spec/controllers/photos_controller_spec.rb'
|
||||
- 'spec/lib/haml/filters/growstuff_markdown_spec.rb'
|
||||
- 'spec/views/posts/edit.html.haml_spec.rb'
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class PhotosController < ApplicationController
|
||||
before_filter :authenticate_member!, except: [:index, :show]
|
||||
before_action :authenticate_member!, except: [:index, :show]
|
||||
load_and_authorize_resource
|
||||
|
||||
# GET /photos
|
||||
@@ -47,37 +47,12 @@ class PhotosController < ApplicationController
|
||||
# POST /photos
|
||||
# POST /photos.json
|
||||
def create
|
||||
@photo = Photo.find_by_flickr_photo_id(params[:photo][:flickr_photo_id]) ||
|
||||
Photo.new(photo_params)
|
||||
@photo.owner_id = current_member.id
|
||||
@photo.set_flickr_metadata
|
||||
|
||||
|
||||
collection = case params[:type]
|
||||
when 'garden'
|
||||
@photo.gardens
|
||||
when 'planting'
|
||||
@photo.plantings
|
||||
when 'harvest'
|
||||
@photo.harvests
|
||||
else
|
||||
nil
|
||||
end
|
||||
|
||||
if collection && has_item_id
|
||||
item = params[:type].camelcase.constantize.find_by_id(params[:id])
|
||||
if item && member_owns_item(item)
|
||||
collection << item unless collection.include?(item)
|
||||
else
|
||||
flash[:alert] = "Could not find this item owned by you"
|
||||
end
|
||||
else
|
||||
flash[:alert] = "Missing or invalid type or id parameter"
|
||||
end
|
||||
find_or_create_photo_from_flickr_photo
|
||||
add_photo_to_collection
|
||||
|
||||
respond_to do |format|
|
||||
if @photo.save
|
||||
format.html { redirect_to @photo, notice: 'Photo was successfully added.' }
|
||||
if @photo.present? && @photo.save
|
||||
format.html { redirect_to photo_path(@photo), notice: 'Photo was successfully added.' }
|
||||
format.json { render json: @photo, status: :created, location: @photo }
|
||||
else
|
||||
format.html { render action: "new" }
|
||||
@@ -117,16 +92,57 @@ class PhotosController < ApplicationController
|
||||
|
||||
private
|
||||
|
||||
def has_item_id
|
||||
def item_id?
|
||||
params.key? :id
|
||||
end
|
||||
|
||||
def member_owns_item(item)
|
||||
item.owner.id == current_member.id
|
||||
def flickr_photo_id_param
|
||||
params[:photo][:flickr_photo_id]
|
||||
end
|
||||
|
||||
def photo_params
|
||||
params.require(:photo).permit(:flickr_photo_id, :owner_id, :title, :license_name,
|
||||
:license_url, :thumbnail_url, :fullsize_url, :link_url)
|
||||
:license_url, :thumbnail_url, :fullsize_url, :link_url)
|
||||
end
|
||||
|
||||
def find_or_create_photo_from_flickr_photo
|
||||
@photo = Photo.find_by(flickr_photo_id: flickr_photo_id_param)
|
||||
@photo = Photo.new(photo_params) unless @photo
|
||||
@photo.owner_id = current_member.id
|
||||
@photo.set_flickr_metadata
|
||||
@photo
|
||||
end
|
||||
|
||||
def which_collection?
|
||||
case params[:type]
|
||||
when "garden" then @photo.gardens
|
||||
when "harvest" then @photo.harvests
|
||||
when "planting" then @photo.plantings
|
||||
else raise "Invalid type"
|
||||
end
|
||||
end
|
||||
|
||||
def add_photo_to_collection
|
||||
collection = which_collection?
|
||||
|
||||
unless collection && item_id?
|
||||
flash[:alert] = "Missing or invalid type or id parameter"
|
||||
return
|
||||
end
|
||||
|
||||
item = find_item_for_photo!
|
||||
collection << item unless collection.include?(item)
|
||||
rescue
|
||||
flash[:alert] = "Could not find this item owned by you"
|
||||
end
|
||||
|
||||
def find_item_for_photo!
|
||||
item_class = case params[:type]
|
||||
when "garden" then Garden
|
||||
when "harvest" then Harvest
|
||||
when "planting" then Planting
|
||||
else raise "Invalid type"
|
||||
end
|
||||
item_class.find_by!(id: params[:id], owner_id: current_member.id)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# frozen_string_literal: true
|
||||
## DEPRECATION NOTICE: Do not add new tests to this file!
|
||||
##
|
||||
## View and controller tests are deprecated in the Growstuff project.
|
||||
@@ -10,14 +11,9 @@
|
||||
## If you submit a pull request containing new view or controller tests, it will not be
|
||||
## merged.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe PhotosController do
|
||||
|
||||
login_member
|
||||
|
||||
def valid_attributes
|
||||
@@ -53,152 +49,127 @@ describe PhotosController do
|
||||
end
|
||||
|
||||
it "assigns a planting id" do
|
||||
get :new, { type: "planting", id: 5 }
|
||||
get :new, type: "planting", id: 5
|
||||
assigns(:id).should eq "5"
|
||||
assigns(:type).should eq "planting"
|
||||
expect(flash[:alert]).not_to be_present
|
||||
end
|
||||
|
||||
it "assigns a harvest id" do
|
||||
get :new, { type: "harvest", id: 5 }
|
||||
get :new, type: "harvest", id: 5
|
||||
assigns(:id).should eq "5"
|
||||
assigns(:type).should eq "harvest"
|
||||
expect(flash[:alert]).not_to be_present
|
||||
end
|
||||
|
||||
it "assigns a garden id" do
|
||||
get :new, { type: "garden", id: 5 }
|
||||
get :new, type: "garden", id: 5
|
||||
assigns(:id).should eq "5"
|
||||
assigns(:type).should eq "garden"
|
||||
expect(flash[:alert]).not_to be_present
|
||||
end
|
||||
|
||||
it "assigns the current set as @current_set" do
|
||||
get :new, { set: 'foo' }
|
||||
get :new, set: 'foo'
|
||||
assigns(:current_set).should eq "foo"
|
||||
expect(flash[:alert]).not_to be_present
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "POST create" do
|
||||
before(:each) do
|
||||
Photo.any_instance.stub(:flickr_metadata).and_return( {
|
||||
title: "A Heartbreaking work of staggering genius",
|
||||
license_name: "CC-BY",
|
||||
license_url: "http://example.com/aybpl",
|
||||
thumbnail_url: "http://example.com/thumb.jpg",
|
||||
fullsize_url: "http://example.com/full.jpg",
|
||||
link_url: "http://example.com"
|
||||
})
|
||||
Photo.any_instance.stub(:flickr_metadata).and_return(title: "A Heartbreaking work of staggering genius",
|
||||
license_name: "CC-BY",
|
||||
license_url: "http://example.com/aybpl",
|
||||
thumbnail_url: "http://example.com/thumb.jpg",
|
||||
fullsize_url: "http://example.com/full.jpg",
|
||||
link_url: "http://example.com")
|
||||
end
|
||||
|
||||
let(:member) { FactoryGirl.create(:member) }
|
||||
let(:garden) { FactoryGirl.create(:garden, owner: member) }
|
||||
let(:planting) { FactoryGirl.create(:planting, garden: garden, owner: member) }
|
||||
let(:harvest) { FactoryGirl.create(:harvest, owner: member) }
|
||||
let(:photo) { FactoryGirl.create(:photo, owner: member) }
|
||||
describe "with valid params" do
|
||||
|
||||
before { controller.stub(:current_member) { member } }
|
||||
it "attaches the photo to a planting" do
|
||||
member = FactoryGirl.create(:member)
|
||||
controller.stub(:current_member) { member }
|
||||
garden = FactoryGirl.create(:garden, owner: member)
|
||||
planting = FactoryGirl.create(:planting, garden: garden, owner: member)
|
||||
photo = FactoryGirl.create(:photo, owner: member)
|
||||
post :create, {photo: { flickr_photo_id: photo.flickr_photo_id },
|
||||
type: "planting",
|
||||
id: planting.id }
|
||||
post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "planting", id: planting.id
|
||||
expect(flash[:alert]).not_to be_present
|
||||
Photo.last.plantings.first.should eq planting
|
||||
end
|
||||
|
||||
it "doesn't attach a photo to a planting twice" do
|
||||
member = FactoryGirl.create(:member)
|
||||
controller.stub(:current_member) { member }
|
||||
garden = FactoryGirl.create(:garden, owner: member)
|
||||
planting = FactoryGirl.create(:planting, garden: garden, owner: member)
|
||||
photo = FactoryGirl.create(:photo, owner: member)
|
||||
post :create, {photo: { flickr_photo_id: photo.flickr_photo_id },
|
||||
type: "planting",
|
||||
id: planting.id }
|
||||
post :create, {photo: { flickr_photo_id: photo.flickr_photo_id },
|
||||
type: "planting",
|
||||
id: planting.id }
|
||||
post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "planting", id: planting.id
|
||||
post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "planting", id: planting.id
|
||||
expect(flash[:alert]).not_to be_present
|
||||
Photo.last.plantings.size.should eq 1
|
||||
end
|
||||
|
||||
it "attaches the photo to a harvest" do
|
||||
member = FactoryGirl.create(:member)
|
||||
controller.stub(:current_member) { member }
|
||||
harvest = FactoryGirl.create(:harvest, owner: member)
|
||||
photo = FactoryGirl.create(:photo, owner: member)
|
||||
post :create, {photo: { flickr_photo_id: photo.flickr_photo_id },
|
||||
type: "harvest",
|
||||
id: harvest.id }
|
||||
post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "harvest", id: harvest.id
|
||||
expect(flash[:alert]).not_to be_present
|
||||
Photo.last.harvests.first.should eq harvest
|
||||
end
|
||||
|
||||
it "doesn't attach a photo to a harvest twice" do
|
||||
member = FactoryGirl.create(:member)
|
||||
controller.stub(:current_member) { member }
|
||||
harvest = FactoryGirl.create(:harvest, owner: member)
|
||||
photo = FactoryGirl.create(:photo, owner: member)
|
||||
post :create, {photo: { flickr_photo_id: photo.flickr_photo_id },
|
||||
type: "harvest",
|
||||
id: harvest.id }
|
||||
post :create, {photo: { flickr_photo_id: photo.flickr_photo_id },
|
||||
type: "harvest",
|
||||
id: harvest.id }
|
||||
post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "harvest", id: harvest.id
|
||||
post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "harvest", id: harvest.id
|
||||
expect(flash[:alert]).not_to be_present
|
||||
Photo.last.harvests.size.should eq 1
|
||||
end
|
||||
|
||||
it "doesn't attach photo to a comment" do
|
||||
comment = FactoryGirl.create(:comment)
|
||||
post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "comment", id: comment.id
|
||||
expect(flash[:alert]).to be_present
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "for the second time" do
|
||||
it "does not add a photo twice" do
|
||||
expect {
|
||||
post :create, {photo: { flickr_photo_id: 1 } }
|
||||
}.to change(Photo, :count).by(1)
|
||||
expect {
|
||||
post :create, {photo: { flickr_photo_id: 1 } }
|
||||
}.to change(Photo, :count).by(0)
|
||||
expect do
|
||||
post :create, photo: { flickr_photo_id: 1 }
|
||||
end.to change(Photo, :count).by(1)
|
||||
expect do
|
||||
post :create, photo: { flickr_photo_id: 1 }
|
||||
end.to change(Photo, :count).by(0)
|
||||
end
|
||||
end
|
||||
|
||||
describe "with matching owners" do
|
||||
before { controller.stub(:current_member) { member } }
|
||||
it "creates the planting/photo link" do
|
||||
member = FactoryGirl.create(:member)
|
||||
controller.stub(:current_member) { member }
|
||||
garden = FactoryGirl.create(:garden, owner: member)
|
||||
planting = FactoryGirl.create(:planting, garden: garden, owner: member)
|
||||
photo = FactoryGirl.create(:photo, owner: member)
|
||||
post :create, {photo: { flickr_photo_id: photo.flickr_photo_id },
|
||||
type: "planting",
|
||||
id: planting.id }
|
||||
post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "planting", id: planting.id
|
||||
expect(flash[:alert]).not_to be_present
|
||||
Photo.last.plantings.first.should eq planting
|
||||
end
|
||||
|
||||
it "creates the harvest/photo link" do
|
||||
member = FactoryGirl.create(:member)
|
||||
controller.stub(:current_member) { member }
|
||||
harvest = FactoryGirl.create(:harvest, owner: member)
|
||||
photo = FactoryGirl.create(:photo, owner: member)
|
||||
post :create, {photo: { flickr_photo_id: photo.flickr_photo_id },
|
||||
type: "harvest",
|
||||
id: harvest.id }
|
||||
post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "harvest", id: harvest.id
|
||||
expect(flash[:alert]).not_to be_present
|
||||
Photo.last.harvests.first.should eq harvest
|
||||
end
|
||||
end
|
||||
|
||||
describe "with mismatched owners" do
|
||||
it "creates the planting/photo link" do
|
||||
let(:photo) { FactoryGirl.create(:photo) }
|
||||
it "does not create the planting/photo link" do
|
||||
# members will be auto-created, and different
|
||||
planting = FactoryGirl.create(:planting)
|
||||
photo = FactoryGirl.create(:photo)
|
||||
post :create, {photo: { flickr_photo_id: photo.flickr_photo_id },
|
||||
type: "planting",
|
||||
id: planting.id }
|
||||
Photo.last.plantings.first.should_not eq planting
|
||||
another_planting = FactoryGirl.create(:planting)
|
||||
post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "planting", id: another_planting.id
|
||||
expect(flash[:alert]).to be_present
|
||||
Photo.last.plantings.first.should_not eq another_planting
|
||||
end
|
||||
|
||||
it "creates the harvest/photo link" do
|
||||
it "does not create the harvest/photo link" do
|
||||
# members will be auto-created, and different
|
||||
harvest = FactoryGirl.create(:harvest)
|
||||
photo = FactoryGirl.create(:photo)
|
||||
post :create, {photo: { flickr_photo_id: photo.flickr_photo_id },
|
||||
type: "harvest",
|
||||
id: harvest.id }
|
||||
Photo.last.harvests.first.should_not eq harvest
|
||||
another_harvest = FactoryGirl.create(:harvest)
|
||||
post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "harvest", id: another_harvest.id
|
||||
expect(flash[:alert]).to be_present
|
||||
Photo.last.harvests.first.should_not eq another_harvest
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user