From 464c570d99c2fe48939515dbc71784871bb846fc Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 6 Dec 2016 21:23:55 +1300 Subject: [PATCH 1/2] Fixed parentheses that are interp-ed as grouped expression --- .rubocop_todo.yml | 9 --------- app/mailers/notifier.rb | 4 ++-- spec/features/harvests/browse_harvests_spec.rb | 4 ++-- spec/models/follow_spec.rb | 2 +- spec/models/member_spec.rb | 4 ++-- spec/views/plantings/show.html.haml_spec.rb | 2 +- 6 files changed, 8 insertions(+), 17 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index cb0b978f6..2b9bfe57b 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -37,15 +37,6 @@ Lint/HandleExceptions: Exclude: - 'lib/tasks/testing.rake' -# Offense count: 8 -Lint/ParenthesesAsGroupedExpression: - Exclude: - - 'app/mailers/notifier.rb' - - 'spec/features/harvests/browse_harvests_spec.rb' - - 'spec/models/follow_spec.rb' - - 'spec/models/member_spec.rb' - - 'spec/views/plantings/show.html.haml_spec.rb' - # Offense count: 15 # Cop supports --auto-correct. # Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments. diff --git a/app/mailers/notifier.rb b/app/mailers/notifier.rb index 69f88ba7e..89a174c52 100644 --- a/app/mailers/notifier.rb +++ b/app/mailers/notifier.rb @@ -16,7 +16,7 @@ class Notifier < ActionMailer::Base @reply_link = reply_link(@notification) # Encrypting - @signed_message = verifier.generate ({ member_id: @notification.recipient.id, type: :send_notification_email }) + @signed_message = verifier.generate(member_id: @notification.recipient.id, type: :send_notification_email) mail(to: @notification.recipient.email, subject: @notification.subject) @@ -29,7 +29,7 @@ class Notifier < ActionMailer::Base @harvests = @member.harvests.first(5) # Encrypting - @signed_message = verifier.generate ({ member_id: @member.id, type: :send_planting_reminder }) + @signed_message = verifier.generate(member_id: @member.id, type: :send_planting_reminder) if @member.send_planting_reminder mail(to: @member.email, diff --git a/spec/features/harvests/browse_harvests_spec.rb b/spec/features/harvests/browse_harvests_spec.rb index d103ec3c9..2a8400c2e 100644 --- a/spec/features/harvests/browse_harvests_spec.rb +++ b/spec/features/harvests/browse_harvests_spec.rb @@ -11,7 +11,7 @@ feature "browse harvests" do feature 'blank optional fields' do let!(:harvest) { create :harvest, :no_description } - before (:each) do + before(:each) do visit harvests_path end @@ -23,7 +23,7 @@ feature "browse harvests" do feature "filled in optional fields" do let!(:harvest) { create :harvest, :long_description } - before (:each) do + before(:each) do visit harvests_path end diff --git a/spec/models/follow_spec.rb b/spec/models/follow_spec.rb index 2fd0b6b80..95b82d8a8 100644 --- a/spec/models/follow_spec.rb +++ b/spec/models/follow_spec.rb @@ -20,7 +20,7 @@ describe Follow do end context "when follow is created" do - before (:each) do + before(:each) do @follow = Follow.create(follower_id: @member1.id, followed_id: @member2.id) end diff --git a/spec/models/member_spec.rb b/spec/models/member_spec.rb index 19e0a9568..d5c9fb9b1 100644 --- a/spec/models/member_spec.rb +++ b/spec/models/member_spec.rb @@ -354,11 +354,11 @@ describe 'member' do member.update_account_after_purchase(product) # stringify to avoid millisecond problems... - member.account.paid_until.to_s.should eq (Time.zone.now + 3.months).to_s + member.account.paid_until.to_s.should eq((Time.zone.now + 3.months).to_s) # and again to make sure it works for currently paid accounts member.update_account_after_purchase(product) - member.account.paid_until.to_s.should eq (Time.zone.now + 3.months + 3.months).to_s + member.account.paid_until.to_s.should eq((Time.zone.now + 3.months + 3.months).to_s) end end diff --git a/spec/views/plantings/show.html.haml_spec.rb b/spec/views/plantings/show.html.haml_spec.rb index e89d6bb92..f6136f8f6 100644 --- a/spec/views/plantings/show.html.haml_spec.rb +++ b/spec/views/plantings/show.html.haml_spec.rb @@ -22,7 +22,7 @@ describe "plantings/show" do ) end - before (:each) do + before(:each) do @member = FactoryGirl.create(:member) controller.stub(:current_user) { @member } @p = create_planting_for(@member) From 05e7a277823765af0d7fa3247d45d5071e179a19 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 7 Dec 2016 10:02:02 +1300 Subject: [PATCH 2/2] Call to verify options stays as a hash --- app/mailers/notifier.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/mailers/notifier.rb b/app/mailers/notifier.rb index 89a174c52..e97fedcda 100644 --- a/app/mailers/notifier.rb +++ b/app/mailers/notifier.rb @@ -16,7 +16,8 @@ class Notifier < ActionMailer::Base @reply_link = reply_link(@notification) # Encrypting - @signed_message = verifier.generate(member_id: @notification.recipient.id, type: :send_notification_email) + message = { member_id: @notification.recipient.id, type: :send_notification_email } + @signed_message = verifier.generate(message) mail(to: @notification.recipient.email, subject: @notification.subject) @@ -29,7 +30,8 @@ class Notifier < ActionMailer::Base @harvests = @member.harvests.first(5) # Encrypting - @signed_message = verifier.generate(member_id: @member.id, type: :send_planting_reminder) + message = { member_id: @member.id, type: :send_planting_reminder } + @signed_message = verifier.generate(message) if @member.send_planting_reminder mail(to: @member.email,