From ae572b96d88561026d6f68d5f3513453c62fd303 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Fri, 22 May 2015 23:31:43 +0300 Subject: [PATCH] #472: Fix specs --- app/models/concerns/build_list_observer.rb | 2 +- app/models/concerns/feed/comment.rb | 60 ++++++++++------------ spec/models/build_list_spec.rb | 8 +-- 3 files changed, 33 insertions(+), 37 deletions(-) diff --git a/app/models/concerns/build_list_observer.rb b/app/models/concerns/build_list_observer.rb index 3cd62edcb..d44353c42 100644 --- a/app/models/concerns/build_list_observer.rb +++ b/app/models/concerns/build_list_observer.rb @@ -37,7 +37,7 @@ module BuildListObserver end build_count = statistic.build_count.to_i new_av_time = ( statistic.average_build_time * build_count + duration.to_i ) / ( build_count + 1 ) - statistic.update_attributes({average_build_time: new_av_time, build_count: build_count + 1}, without_protection: true) + statistic.update_attributes(average_build_time: new_av_time, build_count: build_count + 1) end end end diff --git a/app/models/concerns/feed/comment.rb b/app/models/concerns/feed/comment.rb index d10ab4322..bc6652f1f 100644 --- a/app/models/concerns/feed/comment.rb +++ b/app/models/concerns/feed/comment.rb @@ -17,22 +17,20 @@ module Feed::Comment if can_notify_on_new_comment?(subscribe) UserMailer.new_comment_notification(self, subscribe.user_id).deliver unless own_comment?(subscribe.user) ActivityFeed.create( - { - user_id: subscribe.user_id, - kind: 'new_comment_notification', - project_owner: project.owner_uname, - project_name: project.name, - creator_id: user_id, - data: { - creator_name: user.name, - creator_email: user.email, - comment_body: body.truncate(100, omission: '…'), - issue_title: commentable.title, - issue_serial_id: commentable.serial_id, - project_id: commentable.project.id, - comment_id: id - } - }, without_protection: true + user_id: subscribe.user_id, + kind: 'new_comment_notification', + project_owner: project.owner_uname, + project_name: project.name, + creator_id: user_id, + data: { + creator_name: user.name, + creator_email: user.email, + comment_body: body.truncate(100, omission: '…'), + issue_title: commentable.title, + issue_serial_id: commentable.serial_id, + project_id: commentable.project.id, + comment_id: id + } ) end end @@ -46,23 +44,21 @@ module Feed::Comment UserMailer.new_comment_notification(self, subscribe.user_id).deliver end ActivityFeed.create( - { - user_id: subscribe.user_id, - kind: 'new_comment_commit_notification', - project_owner: project.owner_uname, - project_name: project.name, - creator_id: user_id, - data: { - creator_name: user.name, - creator_email: user.email, + user_id: subscribe.user_id, + kind: 'new_comment_commit_notification', + project_owner: project.owner_uname, + project_name: project.name, + creator_id: user_id, + data: { + creator_name: user.name, + creator_email: user.email, - comment_body: body.truncate(100, omission: '…'), - commit_message: commentable.message.truncate(70, omission: '…'), - commit_id: commentable.id, - project_id: project.id, - comment_id: id - } - }, without_protection: true + comment_body: body.truncate(100, omission: '…'), + commit_message: commentable.message.truncate(70, omission: '…'), + commit_id: commentable.id, + project_id: project.id, + comment_id: id + } ) end end diff --git a/spec/models/build_list_spec.rb b/spec/models/build_list_spec.rb index cfb08ed7b..10814759a 100644 --- a/spec/models/build_list_spec.rb +++ b/spec/models/build_list_spec.rb @@ -191,8 +191,8 @@ describe BuildList do auto_publish_status: BuildList::AUTO_PUBLISH_STATUS_DEFAULT, project: project ) - bl.update_attributes({commit_hash: bl.project.repo.commits('master').last.id, - status: BuildList::BUILD_PUBLISH}, without_protection: true) + bl.update_attributes(commit_hash: bl.project.repo.commits('master').last.id, + status: BuildList::BUILD_PUBLISH) bl.published expect(subject.count).to eq 1 end @@ -287,7 +287,7 @@ describe BuildList do let(:build_list) { FactoryGirl.create(:build_list) } before do - build_list.update_attributes({ status: BuildList::SUCCESS }, without_protection: true) + build_list.update_attributes(status: BuildList::SUCCESS) allow(build_list).to receive(:valid_branch_for_publish?).and_return(true) end @@ -315,7 +315,7 @@ describe BuildList do let(:build_list) { FactoryGirl.create(:build_list) } before do - build_list.update_attributes({ status: BuildList::SUCCESS }, without_protection: true) + build_list.update_attributes(status: BuildList::SUCCESS) end it 'returns true for eligible build' do