merge from upstream dev

This commit is contained in:
Mackenzie Morgan committed 2016-11-29 09:37:25 -05:00
commit 832719b01a
282 files changed
+669 -2441

No files matched your search

+8
View File
@@ -16,6 +16,14 @@ Style/FileName:
Style/StringLiterals:
Enabled: false
Style/MultilineMethodCallIndentation:
EnforcedStyle: indented
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
# SupportedStyles: with_first_parameter, with_fixed_indentation
Style/AlignParameters:
EnforcedStyle: with_fixed_indentation
Metrics/MethodLength:
Description: 'Avoid methods longer than 30 lines of code.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#short-methods'
-892
View File
@@ -32,15 +32,6 @@ Lint/AssignmentInCondition:
Exclude:
- 'app/models/member.rb'
# Offense count: 5
# Cop supports --auto-correct.
# Configuration parameters: AlignWith, SupportedStyles.
# SupportedStyles: either, start_of_block, start_of_line
Lint/BlockAlignment:
Exclude:
- 'spec/features/signin_spec.rb'
- 'spec/models/seed_spec.rb'
# Offense count: 2
# Cop supports --auto-correct.
Lint/DeprecatedClassMethods:
@@ -48,17 +39,6 @@ Lint/DeprecatedClassMethods:
- 'app/controllers/robots_controller.rb'
- 'config/boot.rb'
# Offense count: 4
# Cop supports --auto-correct.
# Configuration parameters: AlignWith, SupportedStyles, AutoCorrect.
# SupportedStyles: keyword, variable, start_of_line
Lint/EndAlignment:
Exclude:
- 'app/controllers/registrations_controller.rb'
- 'app/controllers/robots_controller.rb'
- 'app/helpers/seeds_helper.rb'
- 'db/migrate/20150201052245_create_cms.rb'
# Offense count: 1
Lint/HandleExceptions:
Exclude:
@@ -297,107 +277,6 @@ Rails/Validation:
- 'app/models/member.rb'
- 'app/models/order_item.rb'
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
# SupportedStyles: outdent, indent
Style/AccessModifierIndentation:
Exclude:
- 'app/controllers/passwords_controller.rb'
# Offense count: 2
# Cop supports --auto-correct.
Style/AlignArray:
Exclude:
- 'spec/models/planting_spec.rb'
# Offense count: 93
# Cop supports --auto-correct.
# Configuration parameters: EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle, SupportedLastArgumentHashStyles.
# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
Style/AlignHash:
Exclude:
- 'app/mailers/notifier.rb'
- 'app/models/crop.rb'
- 'app/models/garden.rb'
- 'app/models/harvest.rb'
- 'app/models/member.rb'
- 'app/models/planting.rb'
- 'app/models/seed.rb'
- 'db/migrate/20150201052245_create_cms.rb'
- 'spec/models/harvest_spec.rb'
- 'spec/models/post_spec.rb'
- 'spec/views/notifications/index.html.haml_spec.rb'
- 'spec/views/photos/show.html.haml_spec.rb'
- 'spec/views/places/_map_attribution.html.haml_spec.rb'
- 'spec/views/plantings/show.html.haml_spec.rb'
- 'spec/views/posts/show.html.haml_spec.rb'
# Offense count: 143
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
# SupportedStyles: with_first_parameter, with_fixed_indentation
Style/AlignParameters:
Exclude:
- 'app/controllers/application_controller.rb'
- 'app/controllers/comments_controller.rb'
- 'app/controllers/gardens_controller.rb'
- 'app/controllers/harvests_controller.rb'
- 'app/controllers/plantings_controller.rb'
- 'app/controllers/products_controller.rb'
- 'app/helpers/application_helper.rb'
- 'app/models/crop.rb'
- 'app/models/garden.rb'
- 'app/models/harvest.rb'
- 'app/models/member.rb'
- 'app/models/planting.rb'
- 'app/models/post.rb'
- 'app/models/product.rb'
- 'app/models/seed.rb'
- 'db/migrate/20150201052245_create_cms.rb'
- 'lib/tasks/hooks.rake'
- 'spec/controllers/order_items_controller_spec.rb'
- 'spec/helpers/gardens_helper_spec.rb'
- 'spec/helpers/harvests_helper_spec.rb'
- 'spec/helpers/plantings_helper_spec.rb'
- 'spec/helpers/seeds_helper_spec.rb'
- 'spec/models/ability_spec.rb'
- 'spec/models/crop_spec.rb'
- 'spec/models/member_spec.rb'
- 'spec/models/order_spec.rb'
- 'spec/models/plant_part_spec.rb'
- 'spec/models/planting_spec.rb'
- 'spec/models/post_spec.rb'
- 'spec/views/account_types/edit.html.haml_spec.rb'
- 'spec/views/account_types/new.html.haml_spec.rb'
- 'spec/views/account_types/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/forums/edit.html.haml_spec.rb'
- 'spec/views/harvests/index.html.haml_spec.rb'
- 'spec/views/notifications/index.html.haml_spec.rb'
- 'spec/views/orders/show.html.haml_spec.rb'
- 'spec/views/photos/edit.html.haml_spec.rb'
- 'spec/views/plant_parts/edit.html.haml_spec.rb'
- 'spec/views/plant_parts/new.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/new.html.haml_spec.rb'
- 'spec/views/plantings/show.html.haml_spec.rb'
- 'spec/views/posts/edit.html.haml_spec.rb'
- 'spec/views/posts/index.html.haml_spec.rb'
- 'spec/views/posts/show.html.haml_spec.rb'
- 'spec/views/products/edit.html.haml_spec.rb'
- 'spec/views/products/new.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/show.html.haml_spec.rb'
- 'spec/views/seeds/show.html.haml_spec.rb'
# Offense count: 12
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
@@ -488,16 +367,6 @@ Style/BracesAroundHashParameters:
- 'spec/views/notifier/notify.html.haml_spec.rb'
- 'spec/views/photos/new.html.haml_spec.rb'
# Offense count: 13
# Cop supports --auto-correct.
# Configuration parameters: IndentWhenRelativeTo, SupportedStyles, IndentOneStep, IndentationWidth.
# SupportedStyles: case, end
Style/CaseIndentation:
Exclude:
- 'app/helpers/application_helper.rb'
- 'app/models/order.rb'
- 'db/migrate/20150201052245_create_cms.rb'
# Offense count: 4
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: nested, compact
@@ -519,52 +388,6 @@ Style/ClassMethods:
- 'app/models/post.rb'
- 'app/models/seed.rb'
# Offense count: 90
# Cop supports --auto-correct.
Style/ClosingParenthesisIndentation:
Exclude:
- 'app/controllers/application_controller.rb'
- 'app/models/account.rb'
- 'app/models/crop.rb'
- 'spec/controllers/order_items_controller_spec.rb'
- 'spec/helpers/gardens_helper_spec.rb'
- 'spec/helpers/harvests_helper_spec.rb'
- 'spec/helpers/plantings_helper_spec.rb'
- 'spec/helpers/seeds_helper_spec.rb'
- 'spec/models/ability_spec.rb'
- 'spec/models/crop_spec.rb'
- 'spec/models/harvest_spec.rb'
- 'spec/models/member_spec.rb'
- 'spec/models/order_spec.rb'
- 'spec/models/plant_part_spec.rb'
- 'spec/models/planting_spec.rb'
- 'spec/models/post_spec.rb'
- 'spec/views/account_types/edit.html.haml_spec.rb'
- 'spec/views/account_types/new.html.haml_spec.rb'
- 'spec/views/account_types/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/forums/edit.html.haml_spec.rb'
- 'spec/views/harvests/index.html.haml_spec.rb'
- 'spec/views/orders/show.html.haml_spec.rb'
- 'spec/views/photos/edit.html.haml_spec.rb'
- 'spec/views/plant_parts/edit.html.haml_spec.rb'
- 'spec/views/plant_parts/new.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/new.html.haml_spec.rb'
- 'spec/views/plantings/show.html.haml_spec.rb'
- 'spec/views/posts/edit.html.haml_spec.rb'
- 'spec/views/products/edit.html.haml_spec.rb'
- 'spec/views/products/new.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/show.html.haml_spec.rb'
# Offense count: 2
# Cop supports --auto-correct.
Style/ColonMethodCall:
@@ -580,37 +403,6 @@ Style/CommentAnnotation:
Exclude:
- 'app/controllers/crops_controller.rb'
# Offense count: 11
# Cop supports --auto-correct.
Style/CommentIndentation:
Exclude:
- 'app/controllers/registrations_controller.rb'
- 'app/models/crop.rb'
- 'config/application.rb'
- 'config/initializers/comfortable_mexican_sofa.rb'
- 'config/routes.rb'
- 'spec/factories/comments.rb'
- 'spec/features/footer_spec.rb'
- 'spec/spec_helper.rb'
- 'spec/views/harvests/new.html.haml_spec.rb'
- 'spec/views/members/show.rss.haml_spec.rb'
- 'spec/views/posts/new.html.haml_spec.rb'
# Offense count: 5
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, SingleLineConditionsOnly.
# SupportedStyles: assign_to_condition, assign_inside_condition
Style/ConditionalAssignment:
Exclude:
- 'app/controllers/crops_controller.rb'
- 'app/controllers/harvests_controller.rb'
- 'app/models/harvest.rb'
- 'app/models/member.rb'
- 'app/controllers/posts_controller.rb'
- 'app/controllers/plantings_controller.rb'
- 'app/controllers/members_controller.rb'
- 'app/controllers/seeds_controller.rb'
# Offense count: 1
# Cop supports --auto-correct.
Style/DefWithParentheses:
@@ -806,442 +598,12 @@ Style/EachForSimpleLoop:
- 'spec/models/crop_spec.rb'
- 'spec/views/home/_crops.html.haml_spec.rb'
# Offense count: 2
# Cop supports --auto-correct.
Style/ElseAlignment:
Exclude:
- 'app/controllers/registrations_controller.rb'
- 'app/helpers/seeds_helper.rb'
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: empty, nil, both
Style/EmptyElse:
Exclude:
# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: AllowAdjacentOneLineDefs.
Style/EmptyLineBetweenDefs:
Exclude:
- 'app/controllers/omniauth_callbacks_controller.rb'
- 'db/migrate/20130601011725_change_flickr_photo_id_to_string.rb'
# Offense count: 536
# Cop supports --auto-correct.
Style/EmptyLines:
Exclude:
- 'app/controllers/gardens_controller.rb'
- 'app/models/follow.rb'
- 'app/models/member.rb'
- 'app/models/post.rb'
- 'config.rb'
- 'config/application.rb'
- 'config/routes.rb'
- 'db/migrate/20120903092956_devise_create_users.rb'
- 'db/seeds.rb'
- 'lib/tasks/growstuff.rake'
- '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/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/roles_controller_spec.rb'
- 'spec/controllers/scientific_names_controller_spec.rb'
- 'spec/controllers/seeds_controller_spec.rb'
- 'spec/controllers/shop_controller_spec.rb'
- 'spec/features/crops/crop_wranglers_spec.rb'
- 'spec/features/signin_spec.rb'
- 'spec/helpers/notifications_helper_spec.rb'
- 'spec/lib/haml/filters/growstuff_markdown_spec.rb'
- 'spec/mailers/notifier_spec.rb'
- 'spec/models/ability_spec.rb'
- 'spec/models/crop_spec.rb'
- 'spec/models/harvest_spec.rb'
- 'spec/models/seed_spec.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/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/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: 2
# Cop supports --auto-correct.
Style/EmptyLinesAroundAccessModifier:
Exclude:
- 'app/controllers/passwords_controller.rb'
- 'app/models/post.rb'
# Offense count: 314
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: empty_lines, no_empty_lines
Style/EmptyLinesAroundBlockBody:
Exclude:
- 'config/environments/test.rb'
- 'config/initializers/comfortable_mexican_sofa.rb'
- 'config/routes.rb'
- 'config/unicorn.rb'
- 'lib/tasks/growstuff.rake'
- '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/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/roles_controller_spec.rb'
- 'spec/controllers/scientific_names_controller_spec.rb'
- 'spec/controllers/shop_controller_spec.rb'
- 'spec/factories/account_types.rb'
- 'spec/factories/crop.rb'
- 'spec/factories/follows.rb'
- 'spec/factories/garden.rb'
- 'spec/factories/member.rb'
- 'spec/factories/post.rb'
- 'spec/factories/scientific_name.rb'
- 'spec/features/crops/browse_crops_spec.rb'
- 'spec/features/crops/crop_detail_page_spec.rb'
- 'spec/features/crops/crop_wranglers_spec.rb'
- 'spec/features/footer_spec.rb'
- 'spec/features/gardens_spec.rb'
- 'spec/features/harvests/browse_harvests_spec.rb'
- 'spec/features/locale_spec.rb'
- 'spec/features/member_profile_spec.rb'
- 'spec/features/signout_spec.rb'
- 'spec/features/signup_spec.rb'
- 'spec/helpers/harvests_helper_spec.rb'
- 'spec/helpers/notifications_helper_spec.rb'
- 'spec/helpers/plantings_helper_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/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/scientific_name_spec.rb'
- 'spec/models/seed_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/database_cleaner.rb'
- 'spec/views/comments/index.rss.haml_spec.rb'
- 'spec/views/comments/new.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/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/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/index.html.haml_spec.rb'
- 'spec/views/gardens/edit.html.haml_spec.rb'
- 'spec/views/gardens/show.html.haml_spec.rb'
- 'spec/views/harvests/index.html.haml_spec.rb'
- 'spec/views/harvests/show.html.haml_spec.rb'
- 'spec/views/home/_blurb.html.haml_spec.rb'
- 'spec/views/home/_members.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/show.html.haml_spec.rb'
- 'spec/views/photos/edit.html.haml_spec.rb'
- 'spec/views/photos/new.html.haml_spec.rb'
- 'spec/views/photos/show.html.haml_spec.rb'
- 'spec/views/places/show.html.haml_spec.rb'
- 'spec/views/plant_parts/index.html.haml_spec.rb'
- 'spec/views/plantings/_form.html.haml_spec.rb'
- 'spec/views/plantings/edit.html.haml_spec.rb'
- 'spec/views/plantings/new.html.haml_spec.rb'
- 'spec/views/posts/_single.html.haml_spec.rb'
- 'spec/views/posts/edit.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/scientific_names/edit.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/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: 21
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: empty_lines, empty_lines_except_namespace, no_empty_lines
Style/EmptyLinesAroundClassBody:
Exclude:
- 'app/controllers/accounts_controller.rb'
- 'app/controllers/application_controller.rb'
- 'app/controllers/home_controller.rb'
- 'app/controllers/passwords_controller.rb'
- 'app/controllers/places_controller.rb'
- 'app/controllers/robots_controller.rb'
- 'app/mailers/notifier.rb'
- 'app/models/account.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/notification.rb'
- 'app/models/order.rb'
- 'app/models/photo.rb'
- 'app/models/plant_part.rb'
- 'app/models/product.rb'
- 'db/migrate/20130518002942_rename_account_detail_to_account.rb'
- 'lib/actions/oauth_signup_action.rb'
# Offense count: 14
# Cop supports --auto-correct.
Style/EmptyLinesAroundMethodBody:
Exclude:
- 'app/controllers/admin/orders_controller.rb'
- 'app/controllers/crops_controller.rb'
- 'app/controllers/follows_controller.rb'
- 'app/controllers/home_controller.rb'
- 'app/controllers/orders_controller.rb'
- 'app/controllers/registrations_controller.rb'
- 'app/models/crop.rb'
- 'app/models/photo.rb'
- 'app/models/seed.rb'
- 'lib/haml/filters/growstuff_markdown.rb'
# Offense count: 14
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: empty_lines, empty_lines_except_namespace, no_empty_lines
Style/EmptyLinesAroundModuleBody:
Exclude:
- 'app/helpers/application_helper.rb'
- 'app/helpers/auto_suggest_helper.rb'
- 'app/helpers/gardens_helper.rb'
- 'app/helpers/harvests_helper.rb'
- 'app/helpers/plantings_helper.rb'
- 'app/helpers/seeds_helper.rb'
- 'lib/geocodable.rb'
- 'lib/haml/filters/escaped_markdown.rb'
- 'lib/haml/filters/growstuff_markdown.rb'
- 'spec/support/feature_helpers.rb'
# Offense count: 1
# Cop supports --auto-correct.
Style/EmptyLiteral:
Exclude:
- 'app/models/member.rb'
# Offense count: 23
# Cop supports --auto-correct.
# Configuration parameters: AllowForAlignment, ForceEqualSignAlignment.
Style/ExtraSpacing:
Exclude:
- 'app/controllers/harvests_controller.rb'
- 'app/controllers/seeds_controller.rb'
- 'app/models/ability.rb'
- 'app/models/crop.rb'
- 'app/models/member.rb'
- 'app/models/post.rb'
- 'bin/rails'
- 'config.ru'
- 'config/environments/test.rb'
- 'db/migrate/20150201052245_create_cms.rb'
- 'script/rails'
- 'spec/features/crops/browse_crops_spec.rb'
- 'spec/lib/actions/oauth_signup_action_spec.rb'
- 'spec/models/planting_spec.rb'
- 'spec/models/role_spec.rb'
- 'spec/views/crops/_planting_advice.html.haml_spec.rb'
- 'spec/views/devise/shared/_links_spec.rb'
- 'spec/views/gardens/show.html.haml_spec.rb'
- 'spec/views/photos/new.html.haml_spec.rb'
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
# SupportedStyles: consistent, special_for_inner_method_call, special_for_inner_method_call_in_parentheses
Style/FirstParameterIndentation:
Exclude:
- 'db/seeds.rb'
# Offense count: 1
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: for, each
@@ -1312,73 +674,6 @@ Style/IfUnlessModifier:
- 'config/initializers/geocoder.rb'
- 'lib/tasks/growstuff.rake'
# Offense count: 18
# Cop supports --auto-correct.
# Configuration parameters: SupportedStyles, IndentationWidth.
# SupportedStyles: special_inside_parentheses, consistent, align_brackets
Style/IndentArray:
EnforcedStyle: consistent
# Offense count: 24
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
# SupportedStyles: special_inside_parentheses, consistent, align_braces
Style/IndentHash:
Exclude:
- 'app/controllers/crops_controller.rb'
- 'app/helpers/application_helper.rb'
- 'app/models/crop.rb'
- 'app/models/member.rb'
- 'app/models/order.rb'
- 'config/environments/development.rb'
- 'config/environments/production.rb'
- 'config/environments/staging.rb'
- 'config/environments/test.rb'
- 'spec/lib/actions/oauth_signup_action_spec.rb'
# Offense count: 25
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: normal, rails
Style/IndentationConsistency:
Exclude:
- 'app/models/crop.rb'
- 'app/models/garden.rb'
- 'app/models/post.rb'
- 'lib/haml/filters/escaped_markdown.rb'
- 'lib/haml/filters/growstuff_markdown.rb'
- 'spec/lib/haml/filters/growstuff_markdown_spec.rb'
- 'spec/models/garden_spec.rb'
- 'spec/support/controller_macros.rb'
- 'spec/views/scientific_names/edit.html.haml_spec.rb'
# Offense count: 29
# Cop supports --auto-correct.
# Configuration parameters: Width.
Style/IndentationWidth:
Exclude:
- 'app/controllers/application_controller.rb'
- 'app/controllers/crops_controller.rb'
- 'app/controllers/registrations_controller.rb'
- 'app/controllers/robots_controller.rb'
- 'app/helpers/seeds_helper.rb'
- 'app/models/crop.rb'
- 'config/initializers/comfortable_mexican_sofa.rb'
- 'db/migrate/20121109130033_add_creation_index_to_updates.rb'
- 'db/migrate/20141119130555_change_follows_member_id_to_follower_id.rb'
- 'lib/tasks/hooks.rake'
- 'spec/controllers/harvests_controller_spec.rb'
- 'spec/features/signin_spec.rb'
- 'spec/lib/haml/filters/growstuff_markdown_spec.rb'
- 'spec/models/garden_spec.rb'
- 'spec/models/seed_spec.rb'
- 'spec/support/controller_macros.rb'
- 'spec/views/crops/index.html.haml_spec.rb'
- 'spec/views/devise/registrations/new_spec.rb'
- 'spec/views/devise/sessions/new_spec.rb'
- 'spec/views/devise/unlocks/new_spec.rb'
- 'spec/views/posts/_single.html.haml_spec.rb'
# Offense count: 7
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
@@ -1388,16 +683,6 @@ Style/Lambda:
- 'spec/controllers/member_controller_spec.rb'
- 'spec/models/photo_spec.rb'
# Offense count: 6
# Cop supports --auto-correct.
Style/LeadingCommentSpace:
Exclude:
- 'app/controllers/application_controller.rb'
- 'app/controllers/omniauth_callbacks_controller.rb'
- 'app/controllers/plantings_controller.rb'
- 'app/controllers/posts_controller.rb'
- 'app/controllers/seeds_controller.rb'
- 'spec/factories/crop.rb'
# Offense count: 3
# Cop supports --auto-correct.
@@ -1501,23 +786,6 @@ Style/MultilineMethodCallBraceLayout:
- 'spec/views/scientific_names/edit.html.haml_spec.rb'
- 'spec/views/scientific_names/show.html.haml_spec.rb'
# Offense count: 4
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
# SupportedStyles: aligned, indented, indented_relative_to_receiver
Style/MultilineMethodCallIndentation:
Exclude:
- 'app/controllers/authentications_controller.rb'
- 'lib/actions/oauth_signup_action.rb'
# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
# SupportedStyles: aligned, indented
Style/MultilineOperationIndentation:
Exclude:
- 'app/controllers/registrations_controller.rb'
# Offense count: 2
Style/MultilineTernaryOperator:
Exclude:
@@ -1723,166 +991,6 @@ Style/SelfAssignment:
Exclude:
- 'app/helpers/crops_helper.rb'
# Offense count: 20
# Cop supports --auto-correct.
Style/SpaceAfterComma:
Exclude:
- 'app/models/crop.rb'
- 'db/seeds.rb'
- 'lib/actions/oauth_signup_action.rb'
- 'spec/models/harvest_spec.rb'
- 'spec/rails_helper.rb'
# Offense count: 6
# Cop supports --auto-correct.
Style/SpaceAfterNot:
Exclude:
- 'app/helpers/harvests_helper.rb'
- 'app/models/crop.rb'
- 'app/models/garden.rb'
# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyleInsidePipes, SupportedStyles.
# SupportedStyles: space, no_space
Style/SpaceAroundBlockParameters:
Exclude:
- 'spec/custom_matchers.rb'
# Offense count: 14
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: space, no_space
Style/SpaceAroundEqualsInParameterDefault:
Exclude:
- 'app/helpers/application_helper.rb'
- 'app/helpers/auto_suggest_helper.rb'
- 'app/models/crop.rb'
- 'app/models/member.rb'
- 'app/models/order.rb'
- 'app/models/planting.rb'
- 'spec/lib/haml/filters/growstuff_markdown_spec.rb'
- 'spec/support/controller_macros.rb'
- 'spec/support/feature_helpers.rb'
# Offense count: 13
# Cop supports --auto-correct.
# Configuration parameters: AllowForAlignment.
Style/SpaceAroundOperators:
Exclude:
- 'app/controllers/harvests_controller.rb'
- 'app/controllers/seeds_controller.rb'
- 'app/models/planting.rb'
- 'app/models/post.rb'
- 'config/environments/test.rb'
- 'db/seeds.rb'
- 'spec/views/crops/_planting_advice.html.haml_spec.rb'
- 'spec/views/gardens/show.html.haml_spec.rb'
- 'spec/views/harvests/index.html.haml_spec.rb'
- 'spec/views/plantings/index.html.haml_spec.rb'
# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: space, no_space
Style/SpaceBeforeBlockBraces:
Exclude:
- 'app/models/crop.rb'
- 'app/models/post.rb'
# Offense count: 1
# Cop supports --auto-correct.
Style/SpaceBeforeComma:
Exclude:
- 'spec/controllers/member_controller_spec.rb'
# Offense count: 16
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
# SupportedStyles: space, no_space
Style/SpaceInsideBlockBraces:
Exclude:
- 'app/helpers/crops_helper.rb'
- 'app/models/crop.rb'
- 'app/models/member.rb'
- 'app/models/post.rb'
- 'spec/factories/member.rb'
- 'spec/rails_helper.rb'
- 'spec/support/elasticsearch_helpers.rb'
- 'spec/views/notifications/new.html.haml_spec.rb'
# Offense count: 43
# Cop supports --auto-correct.
Style/SpaceInsideBrackets:
Exclude:
- 'app/models/crop.rb'
- 'config/initializers/devise.rb'
- 'spec/controllers/member_controller_spec.rb'
- 'spec/factories/member.rb'
- 'spec/models/crop_spec.rb'
- 'spec/models/member_spec.rb'
- 'spec/views/crops/index.html.haml_spec.rb'
- 'spec/views/crops/wrangle.html.haml_spec.rb'
- 'spec/views/forums/index.html.haml_spec.rb'
- 'spec/views/members/index.html.haml_spec.rb'
- 'spec/views/notifications/index.html.haml_spec.rb'
- 'spec/views/orders/index.html.haml_spec.rb'
- 'spec/views/plantings/index.rss.haml_spec.rb'
- 'spec/views/seeds/index.rss.haml_spec.rb'
# Offense count: 137
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SupportedStyles.
# SupportedStyles: space, no_space, compact
Style/SpaceInsideHashLiteralBraces:
Exclude:
- 'app/controllers/admin/orders_controller.rb'
- 'app/controllers/crops_controller.rb'
- 'app/models/crop.rb'
- 'app/models/harvest.rb'
- 'app/models/member.rb'
- 'app/models/planting.rb'
- 'app/models/seed.rb'
- 'db/migrate/20150201052245_create_cms.rb'
- 'lib/geocodable.rb'
- 'spec/controllers/admin/orders_controller_spec.rb'
- 'spec/controllers/comments_controller_spec.rb'
- 'spec/controllers/gardens_controller_spec.rb'
- 'spec/controllers/harvests_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/plantings_controller_spec.rb'
- 'spec/controllers/seeds_controller_spec.rb'
- 'spec/views/notifications/show.html.haml_spec.rb'
- 'spec/views/photos/new.html.haml_spec.rb'
- 'spec/views/posts/_single.html.haml_spec.rb'
- 'spec/views/posts/show.html.haml_spec.rb'
# Offense count: 5
# Cop supports --auto-correct.
Style/SpaceInsideParens:
Exclude:
- 'app/models/crop.rb'
- 'config/environments/test.rb'
- 'spec/lib/haml/filters/growstuff_markdown_spec.rb'
- 'spec/views/posts/edit.html.haml_spec.rb'
# Offense count: 12
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: space, no_space
Style/SpaceInsideStringInterpolation:
Exclude:
- 'app/controllers/follows_controller.rb'
- 'app/controllers/robots_controller.rb'
- 'spec/controllers/robots_controller_spec.rb'
- 'spec/features/crops/crop_detail_page_spec.rb'
- 'spec/features/rss/plantings_spec.rb'
- 'spec/features/rss/posts_spec.rb'
- 'spec/features/rss/seeds_spec.rb'
# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: SupportedStyles.
-1
View File
@@ -43,5 +43,4 @@ class AccountsController < ApplicationController
def account_params
params.require(:account).permit(:account_type_id, :member_id, :paid_until)
end
end
+1 -2
View File
@@ -8,7 +8,7 @@ class Admin::OrdersController < ApplicationController
def search
authorize! :manage, :all
@orders = Order.search({by: params[:search_by], for: params[:search_text]})
@orders = Order.search({ by: params[:search_by], for: params[:search_text] })
if @orders.empty?
flash[:alert] = "Couldn't find order with #{params[:search_by]} = #{params[:search_text]}"
@@ -17,6 +17,5 @@ class Admin::OrdersController < ApplicationController
respond_to do |format|
format.html # index.html.haml
end
end
end
+2 -3
View File
@@ -14,7 +14,7 @@ class ApplicationController < ActionController::Base
request.path != "/members/confirmation" &&
request.path != "/members/sign_out" &&
!request.xhr?)
store_location_for(:member, request.fullpath)
store_location_for(:member, request.fullpath)
end
end
@@ -73,10 +73,9 @@ class ApplicationController < ActionController::Base
:bio, :location, :latitude, :longitude,
# email settings
:show_email, :newsletter, :send_notification_email, :send_planting_reminder,
#update password
# update password
:current_password
)
end
end
end
@@ -10,15 +10,15 @@ class AuthenticationsController < ApplicationController
name = Growstuff::OauthSignupAction.new.determine_name(auth)
@authentication = current_member.authentications
.create_with(
name: name,
token: auth['credentials']['token'],
secret: auth['credentials']['secret']
)
.find_or_create_by(
provider: auth['provider'],
uid: auth['uid'],
name: name)
.create_with(
name: name,
token: auth['credentials']['token'],
secret: auth['credentials']['secret']
)
.find_or_create_by(
provider: auth['provider'],
uid: auth['uid'],
name: name)
flash[:notice] = "Authentication successful."
else
+24 -26
View File
@@ -11,11 +11,11 @@ class CropsController < ApplicationController
@sort = params[:sort]
if @sort == 'alpha'
# alphabetical order
@crops = Crop.includes(:scientific_names, {plantings: :photos})
@crops = Crop.includes(:scientific_names, { plantings: :photos })
@paginated_crops = @crops.approved.paginate(page: params[:page])
else
# default to sorting by popularity
@crops = Crop.popular.includes(:scientific_names, {plantings: :photos})
@crops = Crop.popular.includes(:scientific_names, { plantings: :photos })
@paginated_crops = @crops.approved.paginate(page: params[:page])
end
@@ -37,14 +37,14 @@ class CropsController < ApplicationController
# GET /crops/wrangle
def wrangle
@approval_status = params[:approval_status]
case @approval_status
when "pending"
@crops = Crop.pending_approval
when "rejected"
@crops = Crop.rejected
else
@crops = Crop.recent
end
@crops = case @approval_status
when "pending"
Crop.pending_approval
when "rejected"
Crop.rejected
else
Crop.recent
end
@crops = @crops.paginate(page: params[:page])
@@ -77,7 +77,7 @@ class CropsController < ApplicationController
# GET /crops/1
# GET /crops/1.json
def show
@crop = Crop.includes(:scientific_names, {plantings: :photos}).find(params[:id])
@crop = Crop.includes(:scientific_names, { plantings: :photos }).find(params[:id])
@posts = @crop.posts.paginate(page: params[:page])
respond_to do |format|
@@ -90,10 +90,10 @@ class CropsController < ApplicationController
}
}
render json: @crop.to_json(include: {
plantings: {
include: owner_structure
}
})
plantings: {
include: owner_structure
}
})
end
end
end
@@ -116,13 +116,11 @@ class CropsController < ApplicationController
@crop = Crop.find(params[:id])
@crop.alternate_names.build if @crop.alternate_names.blank?
@crop.scientific_names.build if @crop.scientific_names.blank?
end
# POST /crops
# POST /crops.json
def create
@crop = Crop.new(crop_params)
if current_member.has_role? :crop_wrangler
@@ -220,14 +218,14 @@ class CropsController < ApplicationController
def crop_params
params.require(:crop).permit(:en_wikipedia_url,
:name,
:parent_id,
:creator_id,
:approval_status,
:request_notes,
:reason_for_rejection,
:rejection_notes, scientific_names_attributes: [:scientific_name,
:_destroy,
:id])
:name,
:parent_id,
:creator_id,
:approval_status,
:request_notes,
:reason_for_rejection,
:rejection_notes, scientific_names_attributes: [:scientific_name,
:_destroy,
:id])
end
end
+2 -3
View File
@@ -5,11 +5,10 @@ class FollowsController < ApplicationController
# POST /follows
def create
@follow = current_member.follows.build(followed_id: follow_params[:followed_id])
if @follow.save
flash[:notice] = "Followed #{ @follow.followed.login_name }"
flash[:notice] = "Followed #{@follow.followed.login_name}"
redirect_to :back
else
flash[:error] = "Already following or error while following."
@@ -23,7 +22,7 @@ class FollowsController < ApplicationController
unfollowed_name = @follow.followed.login_name
@follow.destroy
flash[:notice] = "Unfollowed #{ unfollowed_name }"
flash[:notice] = "Unfollowed #{unfollowed_name}"
redirect_to root_path
end
+1 -2
View File
@@ -2,7 +2,6 @@ class GardensController < ApplicationController
before_filter :authenticate_member!, except: [:index, :show]
load_and_authorize_resource
# GET /gardens
# GET /gardens.json
def index
@@ -98,6 +97,6 @@ class GardensController < ApplicationController
def garden_params
params.require(:garden).permit(:name, :slug, :owner_id, :description, :active,
:location, :latitude, :longitude, :area, :area_unit)
:location, :latitude, :longitude, :area, :area_unit)
end
end
+9 -9
View File
@@ -7,13 +7,13 @@ class HarvestsController < ApplicationController
def index
@owner = Member.find_by_slug(params[:owner])
@crop = Crop.find_by_slug(params[:crop])
if @owner
@harvests = @owner.harvests.includes(:owner, :crop)
elsif @crop
@harvests = @crop.harvests.includes(:owner, :crop)
else
@harvests = Harvest.includes(:owner, :crop)
end
@harvests = if @owner
@owner.harvests.includes(:owner, :crop)
elsif @crop
@crop.harvests.includes(:owner, :crop)
else
Harvest.includes(:owner, :crop)
end
respond_to do |format|
format.html { @harvests = @harvests.paginate(page: params[:page]) }
@@ -32,7 +32,7 @@ class HarvestsController < ApplicationController
@harvest = Harvest.new('harvested_at' => Date.today)
# using find_by_id here because it returns nil, unlike find
@crop = Crop.find_by_id(params[:crop_id]) || Crop.new
@crop = Crop.find_by_id(params[:crop_id]) || Crop.new
respond_to do |format|
format.html # new.html.erb
@@ -95,6 +95,6 @@ class HarvestsController < ApplicationController
def harvest_params
params.require(:harvest).permit(:crop_id, :harvested_at, :description, :owner_id,
:quantity, :unit, :weight_quantity, :weight_unit, :plant_part_id, :slug, :si_weight)
:quantity, :unit, :weight_quantity, :weight_unit, :plant_part_id, :slug, :si_weight)
end
end
-2
View File
@@ -2,7 +2,6 @@ class HomeController < ApplicationController
skip_authorize_resource
def index
# we were previously generating a lot of instance variables like
# @members_count and @interesting_crops in here, but now we call
# the relevant class methods directly in the view, so that fragment
@@ -12,5 +11,4 @@ class HomeController < ApplicationController
format.html # index.html.haml
end
end
end
+9 -9
View File
@@ -7,18 +7,18 @@ class MembersController < ApplicationController
def index
@sort = params[:sort]
if @sort == 'recently_joined'
@members = Member.confirmed.recently_joined.paginate(page: params[:page])
else
@members = Member.confirmed.paginate(page: params[:page])
end
@members = if @sort == 'recently_joined'
Member.confirmed.recently_joined.paginate(page: params[:page])
else
Member.confirmed.paginate(page: params[:page])
end
respond_to do |format|
format.html # index.html.haml
format.json {
render json: @members.to_json(only: [
:id, :login_name, :slug, :bio, :created_at, :location, :latitude, :longitude
])
:id, :login_name, :slug, :bio, :created_at, :location, :latitude, :longitude
])
}
end
end
@@ -38,8 +38,8 @@ class MembersController < ApplicationController
format.html # show.html.haml
format.json {
render json: @member.to_json(only: [
:id, :login_name, :bio, :created_at, :slug, :location, :latitude, :longitude
])
:id, :login_name, :bio, :created_at, :slug, :location, :latitude, :longitude
])
}
format.rss { render(
layout: false,
@@ -10,6 +10,7 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
def facebook
create
end
def failure
flash[:alert] = "Authentication failed."
redirect_to request.env['omniauth.origin'] || "/"
@@ -27,7 +28,7 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
@authentication = action.establish_authentication(auth, member)
unless action.member_created?
sign_in_and_redirect member, event: :authentication #this will throw if @user is not activated
sign_in_and_redirect member, event: :authentication # this will throw if @user is not activated
set_flash_message(:notice, :success, kind: auth['provider']) if is_navigational_format?
else
raise "Invalid provider" unless ['facebook', 'twitter', 'flickr'].index(auth['provider'].to_s)
-2
View File
@@ -49,7 +49,6 @@ class OrdersController < ApplicationController
format.html { render action: "show" }
end
end
end
def complete
@@ -78,7 +77,6 @@ class OrdersController < ApplicationController
respond_to do |format|
format.html # new.html.erb
end
end
def cancel
+1 -1
View File
@@ -1,6 +1,6 @@
class PasswordsController < Devise::PasswordsController
protected
protected
def after_resetting_password_path_for(resource)
root_path
end
+1 -1
View File
@@ -102,7 +102,7 @@ class PhotosController < ApplicationController
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
+4 -5
View File
@@ -7,8 +7,8 @@ class PlacesController < ApplicationController
# json response is whatever we want to map here
format.json do
render json: Member.located.to_json(only: [
:id, :login_name, :slug, :location, :latitude, :longitude
])
:id, :login_name, :slug, :location, :latitude, :longitude
])
end
end
end
@@ -22,8 +22,8 @@ class PlacesController < ApplicationController
format.html # show.html.haml
format.json do
render json: @nearby_members.to_json(only: [
:id, :login_name, :slug, :location, :latitude, :longitude
])
:id, :login_name, :slug, :location, :latitude, :longitude
])
end
end
end
@@ -43,5 +43,4 @@ class PlacesController < ApplicationController
end
end
end
end
+10 -10
View File
@@ -7,18 +7,18 @@ class PlantingsController < ApplicationController
def index
@owner = Member.find_by_slug(params[:owner])
@crop = Crop.find_by_slug(params[:crop])
if @owner
@plantings = @owner.plantings.includes(:owner, :crop, :garden).paginate(page: params[:page])
elsif @crop
@plantings = @crop.plantings.includes(:owner, :crop, :garden).paginate(page: params[:page])
else
@plantings = Planting.includes(:owner, :crop, :garden).paginate(page: params[:page])
end
@plantings = if @owner
@owner.plantings.includes(:owner, :crop, :garden).paginate(page: params[:page])
elsif @crop
@crop.plantings.includes(:owner, :crop, :garden).paginate(page: params[:page])
else
Planting.includes(:owner, :crop, :garden).paginate(page: params[:page])
end
respond_to do |format|
format.html { @plantings = @plantings.paginate(page: params[:page]) }
format.json { render json: @plantings }
format.rss { render layout: false } #index.rss.builder
format.rss { render layout: false } # index.rss.builder
format.csv do
specifics = (@owner ? "#{@owner.login_name}-" : @crop ? "#{@crop.name}-" : nil)
@filename = "Growstuff-#{specifics}Plantings-#{Time.zone.now.to_s(:number)}.csv"
@@ -120,8 +120,8 @@ class PlantingsController < ApplicationController
def planting_params
params.require(:planting).permit(:crop_id, :description, :garden_id, :planted_at,
:quantity, :sunniness, :planted_from, :owner_id, :finished,
:finished_at)
:quantity, :sunniness, :planted_from, :owner_id, :finished,
:finished_at)
end
def update_days_before_maturity(planting, crop_id)
+6 -6
View File
@@ -7,16 +7,16 @@ class PostsController < ApplicationController
def index
@author = Member.find_by_slug(params[:author])
if @author
@posts = @author.posts.includes(:author, { comments: :author }).paginate(page: params[:page])
else
@posts = Post.includes(:author, { comments: :author }).paginate(page: params[:page])
end
@posts = if @author
@author.posts.includes(:author, { comments: :author }).paginate(page: params[:page])
else
Post.includes(:author, { comments: :author }).paginate(page: params[:page])
end
respond_to do |format|
format.html # index.html.haml
format.json { render json: @posts }
format.rss { render layout: false } #index.rss.builder
format.rss { render layout: false } # index.rss.builder
end
end
+1 -1
View File
@@ -74,6 +74,6 @@ class ProductsController < ApplicationController
def product_params
params.require(:product).permit(:description, :min_price, :recommended_price, :name,
:account_type_id, :paid_months)
:account_type_id, :paid_months)
end
end
+9 -11
View File
@@ -8,23 +8,22 @@ class RegistrationsController < Devise::RegistrationsController
render "edit"
end
# we need this subclassed method so that Devise doesn't force people to
# change their password every time they want to edit their settings.
# we also check that they give their current password to change their password.
# Code copied from
# https://github.com/plataformatec/devise/wiki/How-To:-Allow-users-to-edit-their-account-without-providing-a-password
# we need this subclassed method so that Devise doesn't force people to
# change their password every time they want to edit their settings.
# we also check that they give their current password to change their password.
# Code copied from
# https://github.com/plataformatec/devise/wiki/How-To:-Allow-users-to-edit-their-account-without-providing-a-password
def update
@member = Member.find(current_member.id)
successfully_updated = if needs_password?(@member, params)
@member.update_with_password(devise_parameter_sanitizer.sanitize(:account_update))
if needs_password?(@member, params)
successfully_updated = @member.update_with_password(devise_parameter_sanitizer.sanitize(:account_update))
else
# remove the virtual current_password attribute
# update_without_password doesn't know how to ignore it
params[:member].delete(:current_password)
@member.update_without_password(devise_parameter_sanitizer.sanitize(:account_update))
successfully_updated = @member.update_without_password(devise_parameter_sanitizer.sanitize(:account_update))
end
if successfully_updated
@@ -35,12 +34,11 @@ class RegistrationsController < Devise::RegistrationsController
else
render "edit"
end
end
end
# check if we need the current password to update fields
def needs_password?(member, params)
params[:member][:password].present? ||
params[:member][:password_confirmation].present?
params[:member][:password_confirmation].present?
end
+1 -6
View File
@@ -1,14 +1,9 @@
class RobotsController < ApplicationController
DEFAULT_FILENAME = 'config/robots.txt'.freeze
def robots
filename = if subdomain && subdomain != 'www'
"config/robots.#{ subdomain }.txt"
end
filename = "config/robots.#{subdomain}.txt" if subdomain && subdomain != 'www'
file_to_render = File.exists?(filename.to_s) ? filename : DEFAULT_FILENAME
render file: file_to_render, layout: false, content_type: 'text/plain'
end
+9 -9
View File
@@ -7,18 +7,18 @@ class SeedsController < ApplicationController
def index
@owner = Member.find_by_slug(params[:owner])
@crop = Crop.find_by_slug(params[:crop])
if @owner
@seeds = @owner.seeds.includes(:owner, :crop).paginate(page: params[:page])
elsif @crop
@seeds = @crop.seeds.includes(:owner, :crop).paginate(page: params[:page])
else
@seeds = Seed.includes(:owner, :crop).paginate(page: params[:page])
end
@seeds = if @owner
@owner.seeds.includes(:owner, :crop).paginate(page: params[:page])
elsif @crop
@crop.seeds.includes(:owner, :crop).paginate(page: params[:page])
else
Seed.includes(:owner, :crop).paginate(page: params[:page])
end
respond_to do |format|
format.html # index.html.erb
format.json { render json: @seeds }
format.rss { render layout: false } #index.rss.builder
format.rss { render layout: false } # index.rss.builder
format.csv do
if @owner
@filename = "Growstuff-#{@owner}-Seeds-#{Time.zone.now.to_s(:number)}.csv"
@@ -49,7 +49,7 @@ class SeedsController < ApplicationController
@seed = Seed.new
# using find_by_id here because it returns nil, unlike find
@crop = Crop.find_by_id(params[:crop_id]) || Crop.new
@crop = Crop.find_by_id(params[:crop_id]) || Crop.new
respond_to do |format|
format.html # new.html.erb
+13 -14
View File
@@ -1,5 +1,4 @@
module ApplicationHelper
def price_in_dollars(price)
return sprintf('%.2f', price / 100.0)
end
@@ -7,7 +6,7 @@ module ApplicationHelper
# 999 cents becomes 9.99 AUD -- for products/orders/etc
def price_with_currency(price)
return sprintf('%.2f %s', price / 100.0,
Growstuff::Application.config.currency)
Growstuff::Application.config.currency)
end
def parse_date(str)
@@ -26,20 +25,20 @@ module ApplicationHelper
def build_alert_classes(alert_type = :info)
classes = 'alert alert-dismissable '
case alert_type.to_sym
when :alert, :danger, :error, :validation_errors
classes += 'alert-danger'
when :warning, :todo
classes += 'alert-warning'
when :notice, :success
classes += 'alert-success'
when :info
classes += 'alert-info'
when :alert, :danger, :error, :validation_errors
classes += 'alert-danger'
when :warning, :todo
classes += 'alert-warning'
when :notice, :success
classes += 'alert-success'
when :info
classes += 'alert-info'
end
classes
end
# Produces a cache key for uniquely identifying cached fragments.
def cache_key_for(klass, identifier="all")
def cache_key_for(klass, identifier = "all")
count = klass.count
max_updated_at = klass.maximum(:updated_at).try(:utc).try(:to_s, :number)
"#{klass.name.downcase.pluralize}/#{identifier}-#{count}-#{max_updated_at}"
@@ -73,9 +72,9 @@ module ApplicationHelper
end
Gravatar.new(member.email).image_url({
size: size,
default: :identicon
})
size: size,
default: :identicon
})
end
# Returns a string with the quantity and the right pluralization for a
+1 -3
View File
@@ -1,6 +1,5 @@
module AutoSuggestHelper
def auto_suggest(resource, source, options={})
def auto_suggest(resource, source, options = {})
if options[:default] && !options[:default].new_record?
default = options[:default]
default_id = options[:default].try(:id)
@@ -23,5 +22,4 @@ module AutoSuggestHelper
type="hidden" name="#{resource}[#{source}_id]" value="#{default_id}">
}.html_safe
end
end
+1 -1
View File
@@ -2,7 +2,7 @@ module CropsHelper
def display_seed_availability(member, crop)
total_quantity = 0
seeds = member.seeds.select {|seed| seed.crop.name == crop.name }
seeds = member.seeds.select { |seed| seed.crop.name == crop.name }
seeds.each do |seed|
total_quantity = total_quantity + seed.quantity if seed.quantity
-1
View File
@@ -1,5 +1,4 @@
module GardensHelper
def display_garden_description(garden)
if garden.description.nil?
"no description provided."
+3 -5
View File
@@ -1,5 +1,4 @@
module HarvestsHelper
def display_quantity(harvest)
human_quantity = display_human_quantity(harvest)
weight = display_weight(harvest)
@@ -16,10 +15,10 @@ module HarvestsHelper
end
def display_human_quantity(harvest)
if ! harvest.quantity.blank? && harvest.quantity > 0
if !harvest.quantity.blank? && harvest.quantity > 0
if harvest.unit == 'individual' # just the number
number_to_human(harvest.quantity, strip_insignificant_zeros: true)
elsif ! harvest.unit.blank? # pluralize anything else
elsif !harvest.unit.blank? # pluralize anything else
return pluralize(number_to_human(harvest.quantity, strip_insignificant_zeros: true), harvest.unit)
else
return "#{number_to_human(harvest.quantity, strip_insignificant_zeros: true)} #{harvest.unit}"
@@ -30,7 +29,7 @@ module HarvestsHelper
end
def display_weight(harvest)
if ! harvest.weight_quantity.blank? && harvest.weight_quantity > 0
if !harvest.weight_quantity.blank? && harvest.weight_quantity > 0
return "#{number_to_human(harvest.weight_quantity, strip_insignificant_zeros: true)} #{harvest.weight_unit}"
else
return nil
@@ -44,5 +43,4 @@ module HarvestsHelper
harvest.description
end
end
end
-2
View File
@@ -1,5 +1,4 @@
module PlantingsHelper
def display_days_before_maturity(planting)
if planting.finished?
0
@@ -41,5 +40,4 @@ module PlantingsHelper
return "#{planting.owner}."
end
end
end
+1 -2
View File
@@ -33,7 +33,7 @@ class Notifier < ActionMailer::Base
if @member.send_planting_reminder
mail(to: @member.email,
subject: "What have you planted lately?")
subject: "What have you planted lately?")
end
end
@@ -51,5 +51,4 @@ class Notifier < ActionMailer::Base
@member, @crop = member, crop
mail(to: @member.email, subject: "#{crop.name.capitalize} has been rejected")
end
end
+1 -1
View File
@@ -108,7 +108,7 @@ class Ability
can :cancel, Order, member_id: member.id, completed_at: nil
can :destroy, Order, member_id: member.id, completed_at: nil
can :create, OrderItem
can :create, OrderItem
# for now, let's not let people mess with individual order items
cannot :read, OrderItem, order: { member_id: member.id }
cannot :update, OrderItem, order: { member_id: member.id, completed_at: nil }
-1
View File
@@ -21,5 +21,4 @@ class Account < ActiveRecord::Base
return paid_until.to_s
end
end
end
-1
View File
@@ -19,5 +19,4 @@ class Comment < ActiveRecord::Base
)
end
end
end
+54 -53
View File
@@ -19,7 +19,7 @@ class Crop < ActiveRecord::Base # rubocop:disable Metrics/ClassLength
belongs_to :parent, class_name: 'Crop'
has_many :varieties, class_name: 'Crop', foreign_key: 'parent_id'
has_and_belongs_to_many :posts
before_destroy {|crop| crop.posts.clear}
before_destroy { |crop| crop.posts.clear }
default_scope { order("lower(name) asc") }
scope :recent, lambda {
@@ -31,7 +31,7 @@ class Crop < ActiveRecord::Base # rubocop:disable Metrics/ClassLength
scope :popular, lambda {
where(approval_status: "approved").reorder("plantings_count desc, lower(name) asc")
}
scope :randomized, lambda {
scope :randomized, lambda {
# ok on sqlite and psql, but not on mysql
where(approval_status: "approved").reorder('random()')
}
@@ -66,24 +66,24 @@ class Crop < ActiveRecord::Base # rubocop:disable Metrics/ClassLength
# use Rails.env as a part of index name (eg. development_growstuff)
index_name [Rails.env, "growstuff"].join('_')
settings index: { number_of_shards: 1 },
analysis: {
tokenizer: {
gs_edgeNGram_tokenizer: {
type: "edgeNGram", # edgeNGram: NGram match from the start of a token
min_gram: 3,
max_gram: 10,
# token_chars: Elasticsearch will split on characters
# that don’t belong to any of these classes
token_chars: [ "letter", "digit" ]
}
},
analyzer: {
gs_edgeNGram_analyzer: {
tokenizer: "gs_edgeNGram_tokenizer",
filter: ["lowercase"]
}
},
} do
analysis: {
tokenizer: {
gs_edgeNGram_tokenizer: {
type: "edgeNGram", # edgeNGram: NGram match from the start of a token
min_gram: 3,
max_gram: 10,
# token_chars: Elasticsearch will split on characters
# that don’t belong to any of these classes
token_chars: ["letter", "digit"]
}
},
analyzer: {
gs_edgeNGram_analyzer: {
tokenizer: "gs_edgeNGram_tokenizer",
filter: ["lowercase"]
}
},
} do
mappings dynamic: 'false' do
indexes :id, type: 'long'
indexes :name, type: 'string', analyzer: 'gs_edgeNGram_analyzer'
@@ -103,13 +103,13 @@ class Crop < ActiveRecord::Base # rubocop:disable Metrics/ClassLength
end
end
def as_indexed_json(options={})
def as_indexed_json(options = {})
self.as_json(
only: [:id, :name, :approval_status],
include: {
scientific_names: { only: :name },
alternate_names: { only: :name }
})
})
end
# update the Elasticsearch index (only if we're using it in this
@@ -196,18 +196,18 @@ class Crop < ActiveRecord::Base # rubocop:disable Metrics/ClassLength
end
def approval_statuses
[ 'rejected', 'pending', 'approved' ]
['rejected', 'pending', 'approved']
end
def reasons_for_rejection
[ "already in database", "not edible", "not enough information", "other" ]
["already in database", "not edible", "not enough information", "other"]
end
# Crop.interesting
# returns a list of interesting crops, for use on the homepage etc
def Crop.interesting
howmany = 12 # max number to find
interesting_crops = []
howmany = 12 # max number to find
interesting_crops = []
Crop.includes(:photos).randomized.each do |c|
break if interesting_crops.size == howmany
next unless c.interesting?
@@ -216,16 +216,16 @@ class Crop < ActiveRecord::Base # rubocop:disable Metrics/ClassLength
return interesting_crops
end
# Crop.create_from_csv(row)
# used by db/seeds.rb and rake growstuff:import_crops
# CSV fields:
# - name (required)
# - en_wikipedia_url (required)
# - parent (name, optional)
# - scientific name (optional, can be picked up from parent if it has one)
# Crop.create_from_csv(row)
# used by db/seeds.rb and rake growstuff:import_crops
# CSV fields:
# - name (required)
# - en_wikipedia_url (required)
# - parent (name, optional)
# - scientific name (optional, can be picked up from parent if it has one)
def Crop.create_from_csv(row)
name,en_wikipedia_url,parent,scientific_names,alternate_names = row
name, en_wikipedia_url, parent, scientific_names, alternate_names = row
cropbot = Member.find_by_login_name('cropbot')
raise "cropbot account not found: run rake db:seed" unless cropbot
@@ -247,12 +247,11 @@ class Crop < ActiveRecord::Base # rubocop:disable Metrics/ClassLength
crop.add_scientific_names_from_csv(scientific_names)
crop.add_alternate_names_from_csv(alternate_names)
end
def add_scientific_names_from_csv(scientific_names)
names_to_add = []
if ! scientific_names.blank? # i.e. we actually passed something in, which isn't a given
if !scientific_names.blank? # i.e. we actually passed something in, which isn't a given
names_to_add = scientific_names.split(%r{,\s*})
elsif parent && parent.scientific_names.size > 0 # pick up from parent
names_to_add = parent.scientific_names.map{|s| s.name}
@@ -273,7 +272,8 @@ class Crop < ActiveRecord::Base # rubocop:disable Metrics/ClassLength
cropbot = Member.find_by_login_name('cropbot')
names_to_add = []
if ! alternate_names.blank? # i.e. we actually passed something in, which isn't a given
if !alternate_names.blank? # i.e. we actually passed something in, which isn't a given
raise "cropbot account not found: run rake db:seed" unless cropbot
names_to_add = alternate_names.split(%r{,\s*})
@@ -293,21 +293,23 @@ class Crop < ActiveRecord::Base # rubocop:disable Metrics/ClassLength
def self.search(query)
if ENV['GROWSTUFF_ELASTICSEARCH'] == "true"
search_str = query.nil? ? "" : query.downcase
response = __elasticsearch__.search( {
# Finds documents which match any field, but uses the _score from
# the best field insead of adding up _score from each field.
query: {
multi_match: {
query: "#{search_str}",
analyzer: "standard",
fields: ["name", "scientific_names.scientific_name", "alternate_names.name"]
}
},
filter: {
term: {approval_status: "approved"}
},
size: 50
}
response = __elasticsearch__.search({
# Finds documents which match any field, but uses the _score from
# the best field insead of adding up _score from each field.
query: {
multi_match: {
query: "#{search_str}",
analyzer: "standard",
fields: ["name",
"scientific_names.scientific_name",
"alternate_names.name"]
}
},
filter: {
term: { approval_status: "approved" }
},
size: 50
}
)
return response.records.to_a
else
@@ -387,5 +389,4 @@ class Crop < ActiveRecord::Base # rubocop:disable Metrics/ClassLength
errors.add(:rejection_notes, "must be added if the reason for rejection is \"other\"")
end
end
end
-2
View File
@@ -11,6 +11,4 @@ class Follow < ActiveRecord::Base
body: "#{self.follower.login_name} just followed you on #{ENV["GROWSTUFF_SITE_NAME"]}. "
)
end
end
-1
View File
@@ -8,5 +8,4 @@ class Forum < ActiveRecord::Base
def to_s
return name
end
end
+11 -12
View File
@@ -9,14 +9,14 @@ class Garden < ActiveRecord::Base
has_and_belongs_to_many :photos
before_destroy do |garden|
photolist = garden.photos.to_a # save a temp copy of the photo list
garden.photos.clear # clear relationship b/w garden and photo
before_destroy do |garden|
photolist = garden.photos.to_a # save a temp copy of the photo list
garden.photos.clear # clear relationship b/w garden and photo
photolist.each do |photo|
photo.destroy_if_unused
end
end
photolist.each do |photo|
photo.destroy_if_unused
end
end
# set up geocoding
geocoded_by :location
@@ -50,9 +50,9 @@ class Garden < ActiveRecord::Base
"acres" => "acre"
}
validates :area_unit, inclusion: { in: AREA_UNITS_VALUES.values,
message: "%{value} is not a valid area unit" },
allow_nil: true,
allow_blank: true
message: "%{value} is not a valid area unit" },
allow_nil: true,
allow_blank: true
after_validation :cleanup_area
@@ -76,7 +76,7 @@ class Garden < ActiveRecord::Base
seen_crops = []
plantings.each do |p|
if (! seen_crops.include?(p.crop))
if (!seen_crops.include?(p.crop))
unique_plantings.push(p)
seen_crops.push(p.crop)
end
@@ -103,5 +103,4 @@ class Garden < ActiveRecord::Base
def default_photo
return photos.first
end
end
+22 -25
View File
@@ -22,9 +22,9 @@ class Harvest < ActiveRecord::Base
validates :crop, approved: true
validates :crop, presence: {message: "must be present and exist in our database"}
validates :crop, presence: { message: "must be present and exist in our database" }
validates :plant_part, presence: {message: "must be present and exist in our database"}
validates :plant_part, presence: { message: "must be present and exist in our database" }
validates :quantity,
numericality: {
@@ -45,9 +45,9 @@ class Harvest < ActiveRecord::Base
"bushels" => "bushel"
}
validates :unit, inclusion: { in: UNITS_VALUES.values,
message: "%{value} is not a valid unit" },
allow_nil: true,
allow_blank: true
message: "%{value} is not a valid unit" },
allow_nil: true,
allow_blank: true
validates :weight_quantity,
numericality: { only_integer: false },
@@ -59,9 +59,9 @@ class Harvest < ActiveRecord::Base
"oz" => "oz"
}
validates :weight_unit, inclusion: { in: WEIGHT_UNITS_VALUES.values,
message: "%{value} is not a valid unit" },
allow_nil: true,
allow_blank: true
message: "%{value} is not a valid unit" },
allow_nil: true,
allow_blank: true
after_validation :cleanup_quantities
@@ -105,24 +105,22 @@ class Harvest < ActiveRecord::Base
string = ''
if self.quantity
string += "#{number_to_human(self.quantity.to_s, strip_insignificant_zeros: true)} "
if self.unit == 'individual'
string += 'individual '
else
if self.quantity == 1
string += "#{self.unit} of "
else
string += "#{self.unit.pluralize} of "
end
end
string += if self.unit == 'individual'
'individual '
elsif self.quantity == 1
"#{self.unit} of "
else
"#{self.unit.pluralize} of "
end
end
if self.unit != 'individual' # buckets of apricot*s*
string += "#{self.crop.name.pluralize}"
elsif self.quantity == 1
string += "#{self.crop.name}"
else
string += "#{self.crop.name.pluralize}"
end
string += if self.unit != 'individual' # buckets of apricot*s*
"#{self.crop.name.pluralize}"
elsif self.quantity == 1
"#{self.crop.name}"
else
"#{self.crop.name.pluralize}"
end
if self.weight_quantity
string += " weighing #{number_to_human(self.weight_quantity, strip_insignificant_zeros: true)}"\
@@ -135,5 +133,4 @@ class Harvest < ActiveRecord::Base
def default_photo
return photos.first || crop.default_photo
end
end
+31 -32
View File
@@ -4,7 +4,7 @@ class Member < ActiveRecord::Base
friendly_id :login_name, use: [:slugged, :finders]
has_many :posts, foreign_key: 'author_id'
has_many :posts, foreign_key: 'author_id'
has_many :comments, foreign_key: 'author_id'
has_many :forums, foreign_key: 'owner_id'
@@ -27,7 +27,6 @@ class Member < ActiveRecord::Base
has_many :photos
default_scope { order("lower(login_name) asc") }
scope :confirmed, -> { where('confirmed_at IS NOT NULL') }
scope :located, -> { where("location <> '' and latitude IS NOT NULL and longitude IS NOT NULL") }
@@ -45,8 +44,8 @@ class Member < ActiveRecord::Base
# :token_authenticatable, :confirmable,
# :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable,
:confirmable, :lockable, :timeoutable, :omniauthable
:recoverable, :rememberable, :trackable, :validatable,
:confirmable, :lockable, :timeoutable, :omniauthable
# set up geocoding
geocoded_by :location
@@ -59,7 +58,7 @@ class Member < ActiveRecord::Base
# Requires acceptance of the Terms of Service
validates_acceptance_of :tos_agreement, allow_nil: true,
accept: true
accept: true
validates :login_name,
length: {
@@ -80,12 +79,12 @@ class Member < ActiveRecord::Base
}
# Give each new member a default garden
after_create {|member| Garden.create(name: "Garden", owner_id: member.id) }
after_create { |member| Garden.create(name: "Garden", owner_id: member.id) }
# and an account record (for paid accounts etc)
# we use find_or_create to avoid accidentally creating a second one,
# which can happen sometimes especially with FactoryGirl associations
after_create {|member| Account.find_or_create_by(member_id: member.id) }
after_create { |member| Account.find_or_create_by(member_id: member.id) }
after_save :update_newsletter_subscription
@@ -159,21 +158,21 @@ class Member < ActiveRecord::Base
# Fetches a collection of photos from Flickr
# Returns a [[page of photos], total] pair.
# Total is needed for pagination.
def flickr_photos(page_num=1, set=nil)
def flickr_photos(page_num = 1, set = nil)
result = false
if set
result = flickr.photosets.getPhotos(
photoset_id: set,
page: page_num,
per_page: 30
)
else
result = flickr.people.getPhotos(
user_id: 'me',
page: page_num,
per_page: 30
)
end
result = if set
flickr.photosets.getPhotos(
photoset_id: set,
page: page_num,
per_page: 30
)
else
flickr.people.getPhotos(
user_id: 'me',
page: page_num,
per_page: 30
)
end
if result
return [result.photo, result.total]
else
@@ -213,7 +212,7 @@ class Member < ActiveRecord::Base
def Member.nearest_to(place)
nearby_members = []
if place
latitude, longitude = Geocoder.coordinates(place, params: {limit: 1})
latitude, longitude = Geocoder.coordinates(place, params: { limit: 1 })
if latitude && longitude
nearby_members = Member.located.sort_by { |x| x.distance_from([latitude, longitude]) }
end
@@ -235,24 +234,24 @@ class Member < ActiveRecord::Base
end
end
def newsletter_subscribe(testing=false)
def newsletter_subscribe(testing = false)
return true if (Rails.env.test? && !testing)
gb = Gibbon::API.new
res = gb.lists.subscribe({
id: Growstuff::Application.config.newsletter_list_id,
email: { email: email },
merge_vars: { login_name: login_name },
double_optin: false # they already confirmed their email with us
})
id: Growstuff::Application.config.newsletter_list_id,
email: { email: email },
merge_vars: { login_name: login_name },
double_optin: false # they already confirmed their email with us
})
end
def newsletter_unsubscribe(testing=false)
def newsletter_unsubscribe(testing = false)
return true if (Rails.env.test? && !testing)
gb = Gibbon::API.new
res = gb.lists.unsubscribe({
id: Growstuff::Application.config.newsletter_list_id,
email: { email: email }
})
id: Growstuff::Application.config.newsletter_list_id,
email: { email: email }
})
end
def already_following?(member)
-1
View File
@@ -26,5 +26,4 @@ class Notification < ActiveRecord::Base
Notifier.notify(self).deliver_later
end
end
end
+28 -29
View File
@@ -27,10 +27,10 @@ class Order < ActiveRecord::Base
items = []
order_items.each do |i|
items.push({
name: i.product.name,
quantity: i.quantity,
amount: i.price
})
name: i.product.name,
quantity: i.quantity,
amount: i.price
})
end
return items
end
@@ -62,35 +62,34 @@ class Order < ActiveRecord::Base
# search orders (used by admin/orders)
# usage: Order.search({ :by => 'member', :for => 'Skud' })
# can search by: member, order_id, paypal_token, paypal_payer_id,
def Order.search(args={})
def Order.search(args = {})
if args[:for]
case args[:by]
when "member"
member = Member.find_by_login_name(args[:for])
if member
return member.orders
end
when "order_id"
order = Order.find_by_id(args[:for])
if order
return [order]
end
when "paypal_token"
order = Order.find_by_paypal_express_token(args[:for])
if order
return [order]
end
when "paypal_payer_id"
order = Order.find_by_paypal_express_payer_id(args[:for])
if order
return [order]
end
when "referral_code"
# coerce to uppercase
return Order.where(referral_code: args[:for].upcase)
when "member"
member = Member.find_by_login_name(args[:for])
if member
return member.orders
end
when "order_id"
order = Order.find_by_id(args[:for])
if order
return [order]
end
when "paypal_token"
order = Order.find_by_paypal_express_token(args[:for])
if order
return [order]
end
when "paypal_payer_id"
order = Order.find_by_paypal_express_payer_id(args[:for])
if order
return [order]
end
when "referral_code"
# coerce to uppercase
return Order.where(referral_code: args[:for].upcase)
end
end
return []
end
end
-2
View File
@@ -34,11 +34,9 @@ class Photo < ActiveRecord::Base
fullsize_url: FlickRaw.url_z(info),
link_url: FlickRaw.url_photopage(info)
}
end
def set_flickr_metadata
self.update_attributes(flickr_metadata)
end
end
-1
View File
@@ -20,5 +20,4 @@ class PlantPart < ActiveRecord::Base
def crops
return super.reorder('name')
end
end
+10 -10
View File
@@ -32,7 +32,7 @@ class Planting < ActiveRecord::Base
validates :crop, approved: true
validates :crop, presence: {message: "must be present and exist in our database"}
validates :crop, presence: { message: "must be present and exist in our database" }
validates :quantity,
numericality: {
@@ -42,9 +42,9 @@ class Planting < ActiveRecord::Base
SUNNINESS_VALUES = %w(sun semi-shade shade)
validates :sunniness, inclusion: { in: SUNNINESS_VALUES,
message: "%{value} is not a valid sunniness value" },
allow_nil: true,
allow_blank: true
message: "%{value} is not a valid sunniness value" },
allow_nil: true,
allow_blank: true
PLANTED_FROM_VALUES = [
'seed',
@@ -60,9 +60,9 @@ class Planting < ActiveRecord::Base
'layering'
]
validates :planted_from, inclusion: { in: PLANTED_FROM_VALUES,
message: "%{value} is not a valid planting method" },
allow_nil: true,
allow_blank: true
message: "%{value} is not a valid planting method" },
allow_nil: true,
allow_blank: true
validate :finished_must_be_after_planted
@@ -105,7 +105,7 @@ class Planting < ActiveRecord::Base
if differences.compact.empty?
nil
else
differences.compact.sum/differences.compact.size
differences.compact.sum / differences.compact.size
end
end
@@ -120,7 +120,7 @@ class Planting < ActiveRecord::Base
return 0 if current_date < planted_at
return 100 if days > days_before_maturity
percent = (days/days_before_maturity*100).to_i
percent = (days / days_before_maturity * 100).to_i
if percent >= 100
percent = 100
@@ -132,7 +132,7 @@ class Planting < ActiveRecord::Base
# return a list of interesting plantings, for the homepage etc.
# we can't do this via a scope (as far as we know) so sadly we have to
# do it this way.
def Planting.interesting(howmany=12, require_photo=true)
def Planting.interesting(howmany = 12, require_photo = true)
interesting_plantings = []
seen_owners = Hash.new(false) # keep track of which owners we've seen already
+13 -13
View File
@@ -5,14 +5,14 @@ class Post < ActiveRecord::Base
belongs_to :forum
has_many :comments, dependent: :destroy
has_and_belongs_to_many :crops
before_destroy {|post| post.crops.clear}
before_destroy { |post| post.crops.clear }
after_save :update_crops_posts_association
# also has_many notifications, but kinda meaningless to get at them
# from this direction, so we won't set up an association for now.
after_create do
recipients = []
sender = self.author.id
sender = self.author.id
self.body.scan(Haml::Filters::GrowstuffMarkdown::MEMBER_REGEX) do |m|
# find member case-insensitively and add to list of recipients
member = Member.where('lower(login_name) = ?', $1.downcase).first
@@ -24,7 +24,7 @@ class Post < ActiveRecord::Base
recipients << member if member && !recipients.include?(member)
end
# don't send notifications to yourself
recipients.map{ |r| r.id }.each do |recipient|
recipients.map { |r| r.id }.each do |recipient|
if recipient != sender
Notification.create(
recipient_id: recipient,
@@ -44,7 +44,6 @@ class Post < ActiveRecord::Base
},
length: { maximum: 255 }
def author_date_subject
# slugs are created before created_at is set
time = created_at || Time.zone.now
@@ -70,14 +69,15 @@ class Post < ActiveRecord::Base
end
private
def update_crops_posts_association
self.crops.destroy_all
# look for crops mentioned in the post. eg. [tomato](crop)
self.body.scan(Haml::Filters::GrowstuffMarkdown::CROP_REGEX) do |m|
# find crop case-insensitively
crop = Crop.where('lower(name) = ?', $1.downcase).first
# create association
self.crops << crop if crop && !self.crops.include?(crop)
end
def update_crops_posts_association
self.crops.destroy_all
# look for crops mentioned in the post. eg. [tomato](crop)
self.body.scan(Haml::Filters::GrowstuffMarkdown::CROP_REGEX) do |m|
# find crop case-insensitively
crop = Crop.where('lower(name) = ?', $1.downcase).first
# create association
self.crops << crop if crop && !self.crops.include?(crop)
end
end
end
-1
View File
@@ -11,5 +11,4 @@ class Product < ActiveRecord::Base
def to_s
name
end
end
+16 -14
View File
@@ -9,7 +9,7 @@ class Seed < ActiveRecord::Base
validates :crop, approved: true
validates :crop, presence: {message: "must be present and exist in our database"}
validates :crop, presence: { message: "must be present and exist in our database" }
validates :quantity,
numericality: {
only_integer: true,
@@ -30,9 +30,10 @@ class Seed < ActiveRecord::Base
TRADABLE_TO_VALUES = %w(nowhere locally nationally internationally)
validates :tradable_to, inclusion: { in: TRADABLE_TO_VALUES,
message: "You may only trade seed nowhere, locally, nationally, or internationally" },
allow_nil: false,
allow_blank: false
message: "You may only trade seed nowhere, "\
"locally, nationally, or internationally" },
allow_nil: false,
allow_blank: false
ORGANIC_VALUES = [
'certified organic',
@@ -40,9 +41,10 @@ class Seed < ActiveRecord::Base
'conventional/non-organic',
'unknown']
validates :organic, inclusion: { in: ORGANIC_VALUES,
message: "You must say whether the seeds are organic or not, or that you don't know" },
allow_nil: false,
allow_blank: false
message: "You must say whether the seeds "\
"are organic or not, or that you don't know" },
allow_nil: false,
allow_blank: false
GMO_VALUES = [
'certified GMO-free',
@@ -50,15 +52,16 @@ class Seed < ActiveRecord::Base
'GMO',
'unknown']
validates :gmo, inclusion: { in: GMO_VALUES,
message: "You must say whether the seeds are genetically modified or not, or that you don't know" },
allow_nil: false,
allow_blank: false
message: "You must say whether the seeds are "\
"genetically modified or not, or that you don't know" },
allow_nil: false,
allow_blank: false
HEIRLOOM_VALUES = %w(heirloom hybrid unknown)
validates :heirloom, inclusion: { in: HEIRLOOM_VALUES,
message: "You must say whether the seeds are heirloom, hybrid, or unknown" },
allow_nil: false,
allow_blank: false
message: "You must say whether the seeds are heirloom, hybrid, or unknown" },
allow_nil: false,
allow_blank: false
def tradable?
if self.tradable_to == 'nowhere'
@@ -89,7 +92,6 @@ class Seed < ActiveRecord::Base
end
return interesting_seeds
end
def seed_slug
+1 -1
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env ruby
APP_PATH = File.expand_path('../../config/application', __FILE__)
APP_PATH = File.expand_path('../../config/application', __FILE__)
require_relative '../config/boot'
require 'rails/commands'
-1
View File
@@ -16,7 +16,6 @@ images_dir = "app/assets/images"
# To disable debugging comments that display the original location of your selectors. Uncomment:
# line_comments = false
# If you prefer the indented syntax, you might want to regenerate this
# project again passing --syntax sass, or you can uncomment this:
preferred_syntax = :sass
+1 -1
View File
@@ -1,4 +1,4 @@
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
require ::File.expand_path('../config/environment', __FILE__)
run Growstuff::Application
+1 -2
View File
@@ -82,7 +82,6 @@ module Growstuff
g.javascripts false
end
# Growstuff-specific configuration variables
config.currency = 'AUD'
config.bot_email = "noreply@growstuff.org"
@@ -90,7 +89,7 @@ module Growstuff
config.user_agent_email = "info@growstuff.org"
Gibbon::API.api_key = ENV['GROWSTUFF_MAILCHIMP_APIKEY'] || 'notarealkey'
# API key can't be blank or tests fail
# API key can't be blank or tests fail
Gibbon::API.timeout = 10
Gibbon::API.throws_exceptions = false
config.newsletter_list_id = ENV['GROWSTUFF_MAILCHIMP_NEWSLETTER_ID']
+5 -5
View File
@@ -48,11 +48,11 @@ Growstuff::Application.configure do
config.action_mailer.delivery_method = :letter_opener
config.action_mailer.smtp_settings = {
port: '587',
address: 'smtp.mandrillapp.com',
user_name: ENV['GROWSTUFF_MANDRILL_USERNAME'],
password: ENV['GROWSTUFF_MANDRILL_APIKEY'],
authentication: :login
port: '587',
address: 'smtp.mandrillapp.com',
user_name: ENV['GROWSTUFF_MANDRILL_USERNAME'],
password: ENV['GROWSTUFF_MANDRILL_APIKEY'],
authentication: :login
}
config.host = 'localhost:8080'
+6 -6
View File
@@ -70,12 +70,12 @@ Growstuff::Application.configure do
config.action_mailer.default_url_options = { host: 'growstuff.org' }
ActionMailer::Base.smtp_settings = {
port: ENV['SPARKPOST_SMTP_PORT'],
address: ENV['SPARKPOST_SMTP_HOST'],
user_name: ENV['SPARKPOST_SMTP_USERNAME'],
password: ENV['SPARKPOST_SMTP_PASSWORD'],
authentication: :login,
enable_starttls_auto: true
port: ENV['SPARKPOST_SMTP_PORT'],
address: ENV['SPARKPOST_SMTP_HOST'],
user_name: ENV['SPARKPOST_SMTP_USERNAME'],
password: ENV['SPARKPOST_SMTP_PASSWORD'],
authentication: :login,
enable_starttls_auto: true
}
ActionMailer::Base.delivery_method = :smtp
+6 -6
View File
@@ -72,12 +72,12 @@ Growstuff::Application.configure do
config.action_mailer.default_url_options = { host: 'staging.growstuff.org' }
ActionMailer::Base.smtp_settings = {
port: ENV['SPARKPOST_SMTP_PORT'],
address: ENV['SPARKPOST_SMTP_HOST'],
user_name: ENV['SPARKPOST_SMTP_USERNAME'],
password: ENV['SPARKPOST_SMTP_PASSWORD'],
authentication: :login,
enable_starttls_auto: true
port: ENV['SPARKPOST_SMTP_PORT'],
address: ENV['SPARKPOST_SMTP_HOST'],
user_name: ENV['SPARKPOST_SMTP_USERNAME'],
password: ENV['SPARKPOST_SMTP_PASSWORD'],
authentication: :login,
enable_starttls_auto: true
}
ActionMailer::Base.delivery_method = :smtp
+15 -16
View File
@@ -26,7 +26,7 @@ Growstuff::Application.configure do
config.action_dispatch.show_exceptions = true
# Disable request forgery protection in test environment
config.action_controller.allow_forgery_protection = false
config.action_controller.allow_forgery_protection = false
# Tell Action Mailer not to deliver emails to the real world.
# The :test delivery method accumulates sent emails in the
@@ -54,7 +54,6 @@ Growstuff::Application.configure do
::STANDARD_GATEWAY = ActiveMerchant::Billing::PaypalBogusGateway.new
::EXPRESS_GATEWAY = ActiveMerchant::Billing::PaypalBogusGateway.new
end
end
Geocoder.configure(lookup: :test)
@@ -101,7 +100,7 @@ Geocoder::Lookup::Test.add_stub(
)
# Unknown location
Geocoder::Lookup::Test.add_stub( "Tatooine", [])
Geocoder::Lookup::Test.add_stub("Tatooine", [])
Capybara.configure do |config|
config.always_include_port = true
@@ -110,16 +109,16 @@ end
OmniAuth.config.test_mode = true
# Fake the omniauth
OmniAuth.config.mock_auth[:facebook] = OmniAuth::AuthHash.new({
provider: 'facebook',
uid: '123545',
info: {
name: "John Testerson",
nickname: 'JohnnyT',
email: 'example.oauth.facebook@example.com',
image: 'http://findicons.com/files/icons/1072/face_avatars/300/i04.png'
},
credentials: {
token: "token",
secret: "donttell"
}
})
provider: 'facebook',
uid: '123545',
info: {
name: "John Testerson",
nickname: 'JohnnyT',
email: 'example.oauth.facebook@example.com',
image: 'http://findicons.com/files/icons/1072/face_avatars/300/i04.png'
},
credentials: {
token: "token",
secret: "donttell"
}
})
@@ -9,7 +9,7 @@ ComfortableMexicanSofa.configure do |config|
# Module responsible for authentication. You can replace it with your own.
# It simply needs to have #authenticate method. See http_auth.rb for reference.
config.admin_auth = 'CmsDeviseAuth'
config.admin_auth = 'CmsDeviseAuth'
# Module responsible for authorization on admin side. It should have #authorize
# method that returns true or false based on params and loaded instance
@@ -91,7 +91,6 @@ ComfortableMexicanSofa.configure do |config|
# Reveal partials that can be overwritten in the admin area.
# Default is false.
# config.reveal_cms_partials = false
end
module CmsDeviseAuth
+5 -5
View File
@@ -26,7 +26,7 @@ Devise.setup do |config|
# session. If you need permissions, you should implement that in a before filter.
# You can also supply a hash where the value is a boolean determining whether
# or not authentication should be aborted when the value is not present.
config.authentication_keys = [ :login ]
config.authentication_keys = [:login]
# Configure parameters from the request object used for authentication. Each entry
# given should be a request method and it will automatically be passed to the
@@ -38,12 +38,12 @@ Devise.setup do |config|
# Configure which authentication keys should be case-insensitive.
# These keys will be downcased upon creating or modifying a user and when used
# to authenticate or find a user. Default is :email.
config.case_insensitive_keys = [ :email ]
config.case_insensitive_keys = [:email]
# Configure which authentication keys should have whitespace stripped.
# These keys will have whitespace before and after removed upon creating or
# modifying a user and when used to authenticate or find a user. Default is :email.
config.strip_whitespace_keys = [ :email, :login_name ]
config.strip_whitespace_keys = [:email, :login_name]
# Tell if authentication through request.params is enabled. True by default.
# It can be set to an array that will enable params authentication only for the
@@ -102,7 +102,7 @@ Devise.setup do |config|
config.reconfirmable = true
# Defines which key will be used when confirming an account
config.confirmation_keys = [ :login ]
config.confirmation_keys = [:login]
# ==> Configuration for :rememberable
# The time the user will be remembered without asking for credentials again.
@@ -158,7 +158,7 @@ Devise.setup do |config|
# ==> Configuration for :recoverable
#
# Defines which key will be used when recovering the password for an account
config.reset_password_keys = [ :login ]
config.reset_password_keys = [:login]
# Time interval you can reset your password with a reset password key.
# Don't put a too small interval or your users won't have the time to
+1 -4
View File
@@ -1,5 +1,4 @@
Growstuff::Application.routes.draw do # rubocop:disable Metrics/BlockLength
get '/robots.txt' => 'robots#robots'
resources :plant_parts
@@ -58,7 +57,6 @@ Growstuff::Application.routes.draw do # rubocop:disable Metrics/BlockLength
get '/members/:login_name/follows' => 'members#view_follows', :as => 'member_follows'
get '/members/:login_name/followers' => 'members#view_followers', :as => 'member_followers'
get '/places' => 'places#index'
get '/places/search' => 'places#search', :as => 'search_places'
get '/places/:place' => 'places#show', :as => 'place'
@@ -91,7 +89,6 @@ Growstuff::Application.routes.draw do # rubocop:disable Metrics/BlockLength
get '/.well-known/acme-challenge/:id' => 'pages#letsencrypt'
# CMS stuff -- must remain LAST
# CMS stuff -- must remain LAST
comfy_route :cms, path: '/', sitemap: false
end
-2
View File
@@ -4,7 +4,6 @@ timeout 30
preload_app true
before_fork do |server, worker|
Signal.trap 'TERM' do
puts 'Unicorn master intercepting TERM and sending myself QUIT instead'
Process.kill 'QUIT', Process.pid
@@ -15,7 +14,6 @@ before_fork do |server, worker|
end
after_fork do |server, worker|
Signal.trap 'TERM' do
puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to sent QUIT'
end
@@ -33,7 +33,6 @@ class DeviseCreateUsers < ActiveRecord::Migration
## Token authenticatable
# t.string :authentication_token
t.timestamps null: true
end
@@ -1,5 +1,5 @@
class AddCreationIndexToUpdates < ActiveRecord::Migration
def change
add_index :updates, [:created_at, :user_id]
add_index :updates, [:created_at, :user_id]
end
end
@@ -2,5 +2,4 @@ class RenameAccountDetailToAccount < ActiveRecord::Migration
def change
rename_table :account_details, :accounts
end
end
@@ -3,6 +3,7 @@ class ChangeFlickrPhotoIdToString < ActiveRecord::Migration
remove_column :photos, :flickr_photo_id
add_column :photos, :flickr_photo_id, :string
end
def down
# Postgres doesn't allow you to cast strings to integers
# Hence there's no way of rolling back this migration without losing
+12 -10
View File
@@ -1,11 +1,11 @@
class CreateCms < ActiveRecord::Migration
def self.up
def self.up # rubocop:disable Metrics/MethodLength
text_limit = case ActiveRecord::Base.connection.adapter_name
when 'PostgreSQL'
{ }
else
{ limit: 16777215 }
end
when 'PostgreSQL'
{}
else
{ limit: 16777215 }
end
# -- Sites --------------------------------------------------------------
create_table :comfy_cms_sites do |t|
@@ -42,7 +42,7 @@ class CreateCms < ActiveRecord::Migration
t.integer :layout_id
t.integer :parent_id
t.integer :target_page_id
t.string :label, null: false
t.string :label, null: false
t.string :slug
t.string :full_path, null: false
t.text :content_cache, text_limit
@@ -80,7 +80,7 @@ class CreateCms < ActiveRecord::Migration
# -- Files --------------------------------------------------------------
create_table :comfy_cms_files do |t|
t.integer :site_id, null: false
t.integer :site_id, null: false
t.integer :block_id
t.string :label, null: false
t.string :file_file_name, null: false
@@ -111,7 +111,8 @@ class CreateCms < ActiveRecord::Migration
t.string :label, null: false
t.string :categorized_type, null: false
end
add_index :comfy_cms_categories, [:site_id, :categorized_type, :label], unique: true,
add_index :comfy_cms_categories, [:site_id, :categorized_type, :label],
unique: true,
name: 'index_cms_categories_on_site_id_and_cat_type_and_label'
create_table :comfy_cms_categorizations, force: true do |t|
@@ -119,7 +120,8 @@ class CreateCms < ActiveRecord::Migration
t.string :categorized_type, null: false
t.integer :categorized_id, null: false
end
add_index :comfy_cms_categorizations, [:category_id, :categorized_type, :categorized_id], unique: true,
add_index :comfy_cms_categorizations, [:category_id, :categorized_type, :categorized_id],
unique: true,
name: 'index_cms_categorizations_on_cat_id_and_catd_type_and_catd_id'
end
+6 -7
View File
@@ -69,16 +69,15 @@ def load_test_users
puts "Warning: unable to open suburbs.csv"
end
# rake parameter (eg. 'rake db:seed member_size=10')
member_size = ENV['member_size'] ? ENV['member_size'].to_i : 3
(1..member_size).each do |i|
@user = Member.new(
login_name: "test#{i}",
email: "test#{i}@example.com",
password: "password#{i}",
tos_agreement: true
login_name: "test#{i}",
email: "test#{i}@example.com",
password: "password#{i}",
tos_agreement: true
)
@user.skip_confirmation!
@user.save!
@@ -88,7 +87,7 @@ def load_test_users
suburb_file.pos = 0 if suburb_file.eof?
row = CSV.parse(suburb_file.readline)
suburb,country,state,latitude,longitude = row[0]
suburb, country, state, latitude, longitude = row[0]
# Using 'update_column' method instead of 'update' so that
# it avoids accessing Geocoding service for faster processing
@user.gardens.first.update_columns(location: suburb, latitude: latitude, longitude: longitude)
@@ -199,7 +198,7 @@ def load_plant_parts
end
def select_random_item(array)
array[rand(0..array.size-1) % array.size]
array[rand(0..array.size - 1) % array.size]
end
load_data
+2 -3
View File
@@ -1,5 +1,4 @@
class Growstuff::OauthSignupAction
#
# Inspects the omniauth information
# and determines if we have an existing member
@@ -12,14 +11,14 @@ class Growstuff::OauthSignupAction
def find_or_create_from_authorization(auth)
member ||= Member.where(email: auth.info.email).first_or_create do |m|
m.email = auth.info.email
m.password = Devise.friendly_token[0,20]
m.password = Devise.friendly_token[0, 20]
# First, try the nickname or friendly generate from the email
m.login_name = auth.info.nickname || auth.info.email.split("@").first.gsub(/[^A-Za-z]+/, '_').underscore
# Do we have a collision with an existing account? Generate a 20 character long random name
# so the user can update it later
m.login_name = Devise.friendly_token[0,20] if Member.where(login_name: m.login_name).any?
m.login_name = Devise.friendly_token[0, 20] if Member.where(login_name: m.login_name).any?
m.preferred_avatar_uri = auth.info.image # assuming the user model has an image
m.skip_confirmation!
+1 -2
View File
@@ -8,7 +8,7 @@ module Geocodable
def geocode
unless self.location.blank?
self.latitude, self.longitude =
Geocoder.coordinates(location, params: {limit: 1})
Geocoder.coordinates(location, params: { limit: 1 })
end
end
@@ -18,5 +18,4 @@ module Geocodable
self.longitude = nil
end
end
end
+3 -4
View File
@@ -9,8 +9,7 @@ module Haml::Filters
end
end
# Register it as the handler for the :escaped_markdown HAML command.
# The automatic system gives us :escapedmarkdown, which is ugly.
defined['escaped_markdown'] = EscapedMarkdown
# Register it as the handler for the :escaped_markdown HAML command.
# The automatic system gives us :escapedmarkdown, which is ugly.
defined['escaped_markdown'] = EscapedMarkdown
end
+3 -6
View File
@@ -9,7 +9,6 @@ module Haml::Filters
include Haml::Filters::Base
def render(text)
# turn [tomato](crop) into [tomato](http://growstuff.org/crops/tomato)
expanded = text.gsub(CROP_REGEX) do |m|
crop_str = $1
@@ -52,12 +51,10 @@ module Haml::Filters
expanded = expanded.gsub(MEMBER_ESCAPE_AT_REGEX, "")
return BlueCloth.new(expanded).to_html
end
end
# Register it as the handler for the :growstuff_markdown HAML command.
# The automatic system gives us :growstuffmarkdown, which is ugly.
defined['growstuff_markdown'] = GrowstuffMarkdown
# Register it as the handler for the :growstuff_markdown HAML command.
# The automatic system gives us :growstuffmarkdown, which is ugly.
defined['growstuff_markdown'] = GrowstuffMarkdown
end
-12
View File
@@ -1,5 +1,4 @@
namespace :growstuff do
desc "Add an admin user, by name"
# usage: rake growstuff:admin_user name=skud
@@ -38,7 +37,6 @@ namespace :growstuff do
end
Rails.cache.delete('full_crop_hierarchy')
puts "Finished loading crops"
end
desc "Send planting reminder email"
@@ -73,10 +71,8 @@ namespace :growstuff do
desc "One-off tasks needed at various times and kept for posterity"
namespace :oneoff do
desc "May 2013: replace any empty notification subjects with (no subject)"
task empty_subjects: :environment do
# this is inefficient as it checks every Notification, but the
# site is small and there aren't many of them, so it shouldn't matter
# for this one-off script.
@@ -88,7 +84,6 @@ namespace :growstuff do
desc "May 2013: replace any empty garden names with Garden"
task empty_garden_names: :environment do
# this is inefficient as it checks every Garden, but the
# site is small and there aren't many of them, so it shouldn't matter
# for this one-off script.
@@ -100,7 +95,6 @@ namespace :growstuff do
end
end
desc "June 2013: create account types and products."
task setup_shop: :environment do
puts "Adding account types..."
@@ -163,7 +157,6 @@ namespace :growstuff do
desc "June 2013: replace nil account_types with free accounts"
task nil_account_type: :environment do
free = AccountType.find_by_name("Free")
raise "Free account type not found: run rake growstuff:oneoff:setup_shop"\
unless free
@@ -177,7 +170,6 @@ namespace :growstuff do
desc "July 2013: replace nil seed.tradable_to with nowhere"
task tradable_to_nowhere: :environment do
Seed.all.each do |s|
unless s.tradable_to
s.tradable_to = 'nowhere'
@@ -188,7 +180,6 @@ namespace :growstuff do
desc "August 2013: set up plantings_count cache on crop"
task reset_crop_plantings_count: :environment do
Crop.find_each do |c|
Crop.reset_counters c.id, :plantings
end
@@ -196,7 +187,6 @@ namespace :growstuff do
desc "August 2013: set default creator on existing crops"
task set_default_crop_creator: :environment do
cropbot = Member.find_by_login_name("cropbot")
raise "cropbot not found: create cropbot member on site or run rake db:seed" unless cropbot
cropbot.account.account_type = AccountType.find_by_name("Staff") # set this just because it's nice
@@ -213,7 +203,6 @@ namespace :growstuff do
sn.save
end
end
end
desc "August 2013: set planting owner"
@@ -339,5 +328,4 @@ namespace :growstuff do
Crop.import
end
end # end oneoff section
end
+2 -2
View File
@@ -1,5 +1,5 @@
desc "Install git hooks"
task :hooks do
FileUtils.symlink '../../script/pre-commit.sh', '.git/hooks/pre-commit',
force: true
FileUtils.symlink '../../script/pre-commit.sh', '.git/hooks/pre-commit',
force: true
end
+2 -2
View File
@@ -2,6 +2,6 @@
# This command will automatically be run when you run "rails"
# with Rails 3 gems installed from the root of your application.
APP_PATH = File.expand_path('../../config/application', __FILE__)
require File.expand_path('../../config/boot', __FILE__)
APP_PATH = File.expand_path('../../config/application', __FILE__)
require File.expand_path('../../config/boot', __FILE__)
require 'rails/commands'
@@ -10,19 +10,13 @@
## If you submit a pull request containing new view or controller tests, it will not be
## merged.
require 'rails_helper'
describe AccountTypesController do
# This automatically creates a "Free" account type
login_member(:admin_member)
def valid_attributes
{ "name" => "MyString" }
end
end
@@ -10,14 +10,9 @@
## If you submit a pull request containing new view or controller tests, it will not be
## merged.
require 'rails_helper'
describe AccountsController do
login_member(:admin_member)
def valid_attributes
@@ -32,5 +27,4 @@ describe AccountsController do
member = FactoryGirl.create(:member)
return member.account
end
end
@@ -10,29 +10,22 @@
## If you submit a pull request containing new view or controller tests, it will not be
## merged.
require 'rails_helper'
describe Admin::OrdersController do
login_member(:admin_member)
describe "GET search" do
it "assigns @orders" do
order = FactoryGirl.create(:order)
get :search, {search_by: 'order_id', search_text: order.id}
get :search, { search_by: 'order_id', search_text: order.id }
assigns(:orders).should eq([order])
end
it "sets an error message if nothing found" do
order = FactoryGirl.create(:order)
get :search, {search_by: 'order_id', search_text: 'foo'}
get :search, { search_by: 'order_id', search_text: 'foo' }
flash[:alert].should match /Couldn't find order with/
end
end
end
@@ -10,14 +10,9 @@
## If you submit a pull request containing new view or controller tests, it will not be
## merged.
require 'rails_helper'
describe AdminController do
login_member(:admin_member)
describe "GET admin/newsletter" do
@@ -10,14 +10,9 @@
## If you submit a pull request containing new view or controller tests, it will not be
## merged.
require 'rails_helper'
describe AuthenticationsController do
before(:each) do
@member = FactoryGirl.create(:member)
sign_in @member
@@ -30,5 +25,4 @@ describe AuthenticationsController do
'credentials' => { 'token' => 'blah', 'secret' => 'blah' }
}
end
end
+5 -11
View File
@@ -10,14 +10,9 @@
## If you submit a pull request containing new view or controller tests, it will not be
## merged.
require 'rails_helper'
describe CommentsController do
before(:each) do
@member = FactoryGirl.create(:member)
sign_in @member
@@ -41,14 +36,14 @@ describe CommentsController do
describe "GET new" do
it "picks up post from params" do
post = FactoryGirl.create(:post)
get :new, {post_id: post.id}
get :new, { post_id: post.id }
assigns(:post).should eq(post)
end
it "assigns the old comments as @comments" do
post = FactoryGirl.create(:post)
old_comment = FactoryGirl.create(:comment, post: post)
get :new, {post_id: post.id}
get :new, { post_id: post.id }
assigns(:comments).should eq [old_comment]
end
@@ -63,7 +58,7 @@ describe CommentsController do
post = FactoryGirl.create(:post)
old_comment = FactoryGirl.create(:comment, post: post)
comment = FactoryGirl.create(:comment, post: post, author: @member)
get :edit, {id: comment.to_param}
get :edit, { id: comment.to_param }
assigns(:comments).should eq([comment, old_comment])
end
end
@@ -72,7 +67,7 @@ describe CommentsController do
describe "with valid params" do
it "redirects to the comment's post" do
comment = Comment.create! valid_attributes
put :update, {id: comment.to_param, comment: valid_attributes}
put :update, { id: comment.to_param, comment: valid_attributes }
response.should redirect_to(comment.post)
end
end
@@ -82,9 +77,8 @@ describe CommentsController do
it "redirects to the post the comment was on" do
comment = Comment.create! valid_attributes
post = comment.post
delete :destroy, {id: comment.to_param}
delete :destroy, { id: comment.to_param }
response.should redirect_to(post)
end
end
end
@@ -10,14 +10,9 @@
## If you submit a pull request containing new view or controller tests, it will not be
## merged.
require 'rails_helper'
describe CropsController do
login_member(:crop_wrangling_member)
def valid_attributes
@@ -61,5 +56,4 @@ describe CropsController do
response.content_type.should eq("application/rss+xml")
end
end
end
@@ -10,14 +10,9 @@
## If you submit a pull request containing new view or controller tests, it will not be
## merged.
require 'rails_helper'
describe ForumsController do
login_member(:admin_member)
def valid_attributes
@@ -31,5 +26,4 @@ describe ForumsController do
def valid_session
{}
end
end
+1 -7
View File
@@ -10,19 +10,13 @@
## If you submit a pull request containing new view or controller tests, it will not be
## merged.
require 'rails_helper'
describe GardensController do
login_member
def valid_attributes
member = FactoryGirl.create(:member)
{name: 'My Garden', owner_id: member.id }
{ name: 'My Garden', owner_id: member.id }
end
end
+18 -24
View File
@@ -10,14 +10,9 @@
## If you submit a pull request containing new view or controller tests, it will not be
## merged.
require 'rails_helper'
describe HarvestsController do
login_member
def valid_attributes
@@ -44,27 +39,27 @@ describe HarvestsController do
end
it "picks up owner from params and shows owner's harvests only" do
get :index, {owner: @member1.slug}
get :index, { owner: @member1.slug }
assigns(:owner).should eq @member1
assigns(:harvests).should eq [@harvest1]
end
it "picks up crop from params and shows the harvests for the crop only" do
get :index, {crop: @maize.name}
get :index, { crop: @maize.name }
assigns(:crop).should eq @maize
assigns(:harvests).should eq [@harvest2]
end
it "generates a csv" do
get :index, {format: "csv"}
response.status.should eq 200
get :index, { format: "csv" }
response.status.should eq 200
end
end
describe "GET show" do
it "assigns the requested harvest as @harvest" do
harvest = Harvest.create! valid_attributes
get :show, {id: harvest.to_param}
get :show, { id: harvest.to_param }
assigns(:harvest).should eq(harvest)
end
end
@@ -79,7 +74,7 @@ describe HarvestsController do
describe "GET edit" do
it "assigns the requested harvest as @harvest" do
harvest = Harvest.create! valid_attributes
get :edit, {id: harvest.to_param}
get :edit, { id: harvest.to_param }
assigns(:harvest).should eq(harvest)
end
end
@@ -88,18 +83,18 @@ describe HarvestsController do
describe "with valid params" do
it "creates a new Harvest" do
expect {
post :create, {harvest: valid_attributes}
post :create, { harvest: valid_attributes }
}.to change(Harvest, :count).by(1)
end
it "assigns a newly created harvest as @harvest" do
post :create, {harvest: valid_attributes}
post :create, { harvest: valid_attributes }
assigns(:harvest).should be_a(Harvest)
assigns(:harvest).should be_persisted
end
it "redirects to the created harvest" do
post :create, {harvest: valid_attributes}
post :create, { harvest: valid_attributes }
response.should redirect_to(Harvest.last)
end
end
@@ -108,14 +103,14 @@ describe HarvestsController do
it "assigns a newly created but unsaved harvest as @harvest" do
# Trigger the behavior that occurs when invalid params are submitted
Harvest.any_instance.stub(:save).and_return(false)
post :create, {harvest: { "crop_id" => "invalid value" }}
post :create, { harvest: { "crop_id" => "invalid value" } }
assigns(:harvest).should be_a_new(Harvest)
end
it "re-renders the 'new' template" do
# Trigger the behavior that occurs when invalid params are submitted
Harvest.any_instance.stub(:save).and_return(false)
post :create, {harvest: { "crop_id" => "invalid value" }}
post :create, { harvest: { "crop_id" => "invalid value" } }
response.should render_template("new")
end
end
@@ -130,18 +125,18 @@ describe HarvestsController do
# receives the :update message with whatever params are
# submitted in the request.
Harvest.any_instance.should_receive(:update).with({ "crop_id" => "1" })
put :update, {id: harvest.to_param, harvest: { "crop_id" => "1" }}
put :update, { id: harvest.to_param, harvest: { "crop_id" => "1" } }
end
it "assigns the requested harvest as @harvest" do
harvest = Harvest.create! valid_attributes
put :update, {id: harvest.to_param, harvest: valid_attributes}
put :update, { id: harvest.to_param, harvest: valid_attributes }
assigns(:harvest).should eq(harvest)
end
it "redirects to the harvest" do
harvest = Harvest.create! valid_attributes
put :update, {id: harvest.to_param, harvest: valid_attributes}
put :update, { id: harvest.to_param, harvest: valid_attributes }
response.should redirect_to(harvest)
end
end
@@ -151,7 +146,7 @@ describe HarvestsController do
harvest = Harvest.create! valid_attributes
# Trigger the behavior that occurs when invalid params are submitted
Harvest.any_instance.stub(:save).and_return(false)
put :update, {id: harvest.to_param, harvest: { "crop_id" => "invalid value" }}
put :update, { id: harvest.to_param, harvest: { "crop_id" => "invalid value" } }
assigns(:harvest).should eq(harvest)
end
@@ -159,7 +154,7 @@ describe HarvestsController do
harvest = Harvest.create! valid_attributes
# Trigger the behavior that occurs when invalid params are submitted
Harvest.any_instance.stub(:save).and_return(false)
put :update, {id: harvest.to_param, harvest: { "crop_id" => "invalid value" }}
put :update, { id: harvest.to_param, harvest: { "crop_id" => "invalid value" } }
response.should render_template("edit")
end
end
@@ -169,15 +164,14 @@ describe HarvestsController do
it "destroys the requested harvest" do
harvest = Harvest.create! valid_attributes
expect {
delete :destroy, {id: harvest.to_param}
delete :destroy, { id: harvest.to_param }
}.to change(Harvest, :count).by(-1)
end
it "redirects to the harvests list" do
harvest = Harvest.create! valid_attributes
delete :destroy, {id: harvest.to_param}
delete :destroy, { id: harvest.to_param }
response.should redirect_to(harvests_url)
end
end
end
-5
View File
@@ -10,14 +10,9 @@
## If you submit a pull request containing new view or controller tests, it will not be
## merged.
require 'rails_helper'
describe HomeController do
describe "GET index" do
end
end
+7 -15
View File
@@ -10,17 +10,12 @@
## If you submit a pull request containing new view or controller tests, it will not be
## merged.
require 'rails_helper'
describe MembersController do
before :each do
@member = FactoryGirl.create(:member)
@posts = [ FactoryGirl.create(:post, author: @member) ]
@posts = [FactoryGirl.create(:post, author: @member)]
@twitter_auth = FactoryGirl.create(:authentication, member: @member)
@flickr_auth = FactoryGirl.create(:flickr_authentication, member: @member)
end
@@ -40,36 +35,34 @@ describe MembersController do
end
describe "GET show" do
it "provides JSON for member profile" do
get :show, { id: @member.id , format: 'json' }
get :show, { id: @member.id, format: 'json' }
response.should be_success
end
it "assigns @posts with the member's posts" do
get :show, {id: @member.id}
get :show, { id: @member.id }
assigns(:posts).should eq(@posts)
end
it "assigns @twitter_auth" do
get :show, {id: @member.id}
get :show, { id: @member.id }
assigns(:twitter_auth).should eq(@twitter_auth)
end
it "assigns @flickr_auth" do
get :show, {id: @member.id}
get :show, { id: @member.id }
assigns(:flickr_auth).should eq(@flickr_auth)
end
it "doesn't show completely nonsense members" do
lambda { get :show, {id: 9999} }.should raise_error(ActiveRecord::RecordNotFound)
lambda { get :show, { id: 9999 } }.should raise_error(ActiveRecord::RecordNotFound)
end
it "doesn't show unconfirmed members" do
@member2 = FactoryGirl.create(:unconfirmed_member)
lambda { get :show, {id: @member2.id} }.should raise_error(ActiveRecord::RecordNotFound)
lambda { get :show, { id: @member2.id } }.should raise_error(ActiveRecord::RecordNotFound)
end
end
describe "GET member's RSS feed" do
@@ -80,5 +73,4 @@ describe MembersController do
response.content_type.should eq("application/rss+xml")
end
end
end
@@ -10,14 +10,9 @@
## If you submit a pull request containing new view or controller tests, it will not be
## merged.
require 'rails_helper'
describe NotificationsController do
login_member
def valid_attributes
@@ -56,14 +51,14 @@ describe NotificationsController do
describe "GET show" do
it "assigns the requested notification as @notification" do
notification = FactoryGirl.create(:notification, recipient_id: subject.current_member.id)
get :show, {id: notification.to_param}
get :show, { id: notification.to_param }
assigns(:notification).should eq(notification)
end
it "assigns the reply link for a post comment" do
notification = FactoryGirl.create(:notification, recipient_id: subject.current_member.id)
get :show, {id: notification.to_param}
get :show, { id: notification.to_param }
assigns(:reply_link).should_not be_nil
assigns(:reply_link).should eq new_comment_url(
post_id: notification.post.id
@@ -72,7 +67,7 @@ describe NotificationsController do
it "marks notifications as read" do
notification = FactoryGirl.create(:notification, recipient_id: subject.current_member.id)
get :show, {id: notification.to_param}
get :show, { id: notification.to_param }
# we need to fetch it from the db again, can't test against the old one
n = Notification.find(notification.id)
n.read.should eq true
@@ -82,7 +77,7 @@ describe NotificationsController do
describe "GET reply" do
it "marks notifications as read" do
notification = FactoryGirl.create(:notification, recipient_id: subject.current_member.id)
get :reply, {id: notification.to_param}
get :reply, { id: notification.to_param }
# we need to fetch it from the db again, can't test against the old one
n = Notification.find(notification.id)
n.read.should eq true
@@ -92,7 +87,7 @@ describe NotificationsController do
describe "GET new" do
it "assigns a recipient" do
@recipient = FactoryGirl.create(:member)
get :new, {recipient_id: @recipient.id }
get :new, { recipient_id: @recipient.id }
assigns(:recipient).should be_an_instance_of(Member)
end
end
@@ -105,6 +100,5 @@ describe NotificationsController do
response.should redirect_to(notifications_path)
end
end
end
end
@@ -10,14 +10,9 @@
## If you submit a pull request containing new view or controller tests, it will not be
## merged.
require 'rails_helper'
describe OrderItemsController do
login_member(:admin_member)
before(:each) do
@@ -33,14 +28,13 @@ describe OrderItemsController do
end
describe "POST create" do
it "redirects to order" do
@order = FactoryGirl.create(:order, member: @member)
post :create, {order_item: {
post :create, { order_item: {
order_id: @order.id,
product_id: @product.id,
price: @product.min_price
}}
} }
response.should redirect_to(OrderItem.last.order)
end
@@ -49,10 +43,10 @@ describe OrderItemsController do
sign_in @member
@product = FactoryGirl.create(:product)
expect {
post :create, {order_item: {
post :create, { order_item: {
product_id: @product.id,
price: @product.min_price
}}
} }
}.to change(Order, :count).by(1)
OrderItem.last.order.should be_an_instance_of Order
end
@@ -62,11 +56,11 @@ describe OrderItemsController do
@order = FactoryGirl.create(:order, member: @member)
@product = FactoryGirl.create(:product, min_price: 1)
expect {
post :create, {order_item: {
post :create, { order_item: {
order_id: @order.id,
product_id: @product.id,
price: 3.33
}}
} }
}.to change(OrderItem, :count).by(1)
OrderItem.last.price.should eq 333
end
+4 -10
View File
@@ -10,14 +10,9 @@
## If you submit a pull request containing new view or controller tests, it will not be
## merged.
require 'rails_helper'
describe OrdersController do
login_member(:admin_member)
def valid_attributes
@@ -33,7 +28,7 @@ describe OrdersController do
member = FactoryGirl.create(:member)
sign_in member
order = Order.create!(member_id: member.id)
get :checkout, {id: order.to_param, referral_code: 'FOOBAR'}
get :checkout, { id: order.to_param, referral_code: 'FOOBAR' }
order.reload
order.referral_code.should eq 'FOOBAR'
end
@@ -42,7 +37,7 @@ describe OrdersController do
member = FactoryGirl.create(:member)
sign_in member
order = Order.create!(member_id: member.id)
get :checkout, {id: order.to_param}
get :checkout, { id: order.to_param }
response.status.should eq 302
response.redirect_url.should match /paypal\.com/
end
@@ -53,7 +48,7 @@ describe OrdersController do
member = FactoryGirl.create(:member)
sign_in member
order = Order.create!(member_id: member.id)
get :complete, {id: order.to_param}
get :complete, { id: order.to_param }
assigns(:order).should eq(order)
end
end
@@ -63,9 +58,8 @@ describe OrdersController do
member = FactoryGirl.create(:member)
sign_in member
order = Order.create!(member_id: member.id)
delete :destroy, {id: order.id}
delete :destroy, { id: order.id }
response.should redirect_to(shop_url)
end
end
end
@@ -10,10 +10,6 @@
## If you submit a pull request containing new view or controller tests, it will not be
## merged.
require 'rails_helper'
describe PlacesController do
@@ -36,7 +32,6 @@ describe PlacesController do
get :show, { place: @member_london.location }
assigns(:nearby_members).should eq [@member_london, @member_south_pole]
end
end
describe "GET search" do
@@ -10,12 +10,7 @@
## If you submit a pull request containing new view or controller tests, it will not be
## merged.
require 'rails_helper'
describe PlantPartsController do
end
+4 -12
View File
@@ -10,14 +10,9 @@
## If you submit a pull request containing new view or controller tests, it will not be
## merged.
require 'rails_helper'
describe PlantingsController do
login_member
def valid_attributes
@@ -43,23 +38,22 @@ describe PlantingsController do
end
it "picks up owner from params and shows owner's plantings only" do
get :index, {owner: @member1.slug}
get :index, { owner: @member1.slug }
assigns(:owner).should eq @member1
assigns(:plantings).should eq [@planting1]
end
it "picks up crop from params and shows the plantings for the crop only" do
get :index, {crop: @maize.name}
get :index, { crop: @maize.name }
assigns(:crop).should eq @maize
assigns(:plantings).should eq [@planting2]
end
end
describe "GET new" do
it "picks up crop from params" do
crop = FactoryGirl.create(:crop)
get :new, {crop_id: crop.id}
get :new, { crop_id: crop.id }
assigns(:crop).should eq(crop)
end
@@ -71,7 +65,7 @@ describe PlantingsController do
it "picks up garden from params" do
member = FactoryGirl.create(:member)
garden = FactoryGirl.create(:garden, owner: member)
get :new, {garden_id: garden.id}
get :new, { garden_id: garden.id }
assigns(:garden).should eq(garden)
end
@@ -89,7 +83,5 @@ describe PlantingsController do
post :create, { planting: valid_attributes }
assigns(:planting).owner.should eq subject.current_member
end
end
end
@@ -10,14 +10,9 @@
## If you submit a pull request containing new view or controller tests, it will not be
## merged.
require 'rails_helper'
describe PostsController do
login_member
def valid_attributes
@@ -43,5 +38,4 @@ describe PostsController do
response.content_type.should eq("application/rss+xml")
end
end
end
@@ -10,14 +10,9 @@
## If you submit a pull request containing new view or controller tests, it will not be
## merged.
require 'rails_helper'
describe ProductsController do
login_member(:admin_member)
def valid_attributes
@@ -31,5 +26,4 @@ describe ProductsController do
def valid_session
{}
end
end
@@ -10,14 +10,9 @@
## If you submit a pull request containing new view or controller tests, it will not be
## merged.
require 'rails_helper'
describe RegistrationsController do
before :each do
@member = FactoryGirl.create(:member)
sign_in @member
@@ -43,5 +38,4 @@ describe RegistrationsController do
assigns(:flickr_auth).should eq @auth
end
end
end
+1 -1
View File
@@ -6,7 +6,7 @@ describe RobotsController do
let(:staging_filename) { 'config/robots.staging.txt' }
before do
@request.host = "#{ subdomain }.localhost.com"
@request.host = "#{subdomain}.localhost.com"
end
context 'subdomain is staging' do
@@ -10,14 +10,9 @@
## If you submit a pull request containing new view or controller tests, it will not be
## merged.
require 'rails_helper'
describe RolesController do
def valid_attributes
{ "name" => "MyString" }
end
@@ -32,5 +27,4 @@ describe RolesController do
assigns(:roles).should eq([Role.find_by_name('admin'), role])
end
end
end
@@ -10,14 +10,9 @@
## If you submit a pull request containing new view or controller tests, it will not be
## merged.
require 'rails_helper'
describe ScientificNamesController do
login_member(:crop_wrangling_member)
before(:each) do
@@ -33,6 +28,5 @@ describe ScientificNamesController do
get :new, { crop_id: 1 }
assigns(:crop).should be_an_instance_of Crop
end
end
end
+1 -5
View File
@@ -10,17 +10,13 @@
## If you submit a pull request containing new view or controller tests, it will not be
## merged.
require 'rails_helper'
describe SeedsController do
describe "GET index" do
it "picks up owner from params" do
owner = FactoryGirl.create(:member)
get :index, {owner: owner.slug}
get :index, { owner: owner.slug }
assigns(:owner).should eq(owner)
end
end
-7
View File
@@ -10,14 +10,9 @@
## If you submit a pull request containing new view or controller tests, it will not be
## merged.
require 'rails_helper'
describe ShopController do
before :each do
@product1 = FactoryGirl.create(:product)
@product2 = FactoryGirl.create(:product)
@@ -46,7 +41,5 @@ describe ShopController do
get :index, {}
assigns(:order).should eq @order
end
end
end
+1 -1
View File
@@ -1,6 +1,6 @@
require 'rspec/expectations'
RSpec::Matchers.define :have_optional do | expected |
RSpec::Matchers.define :have_optional do |expected|
match do |actual|
actual.has_selector? "#{expected} + span", text: '(Optional)'
end
-1
View File
@@ -24,5 +24,4 @@ FactoryGirl.define do
is_permanent_paid true
end
end
end
Loaded 100 of 282 files, more files were not shown because too many files have changed in this diff. Show more