Commit d277ec55 authored by Luke Duncalfe's avatar Luke Duncalfe

Update specs to use #update! rather than #update

As #update! will fail with an error if the update is not successful.
parent 6d7b4d54
......@@ -49,13 +49,13 @@ describe ApprovableForRule do
end
it 'returns true when authors can approve' do
project.update(merge_requests_author_approval: true)
project.update!(merge_requests_author_approval: true)
expect(merge_request.can_approve?(author)).to be true
end
it 'returns false when authors cannot approve' do
project.update(merge_requests_author_approval: false)
project.update!(merge_requests_author_approval: false)
expect(merge_request.can_approve?(author)).to be false
end
......@@ -63,13 +63,13 @@ describe ApprovableForRule do
context 'and author is not an approver' do
it 'returns true when authors can approve' do
project.update(merge_requests_author_approval: true)
project.update!(merge_requests_author_approval: true)
expect(merge_request.can_approve?(author)).to be true
end
it 'returns false when authors cannot approve' do
project.update(merge_requests_author_approval: false)
project.update!(merge_requests_author_approval: false)
expect(merge_request.can_approve?(author)).to be false
end
......@@ -89,13 +89,13 @@ describe ApprovableForRule do
end
it 'return true when committers can approve' do
project.update(merge_requests_disable_committers_approval: false)
project.update!(merge_requests_disable_committers_approval: false)
expect(merge_request.can_approve?(user)).to be true
end
it 'return false when committers cannot approve' do
project.update(merge_requests_disable_committers_approval: true)
project.update!(merge_requests_disable_committers_approval: true)
expect(merge_request.can_approve?(user)).to be false
end
......@@ -103,13 +103,13 @@ describe ApprovableForRule do
context 'and committer is not an approver' do
it 'return true when committers can approve' do
project.update(merge_requests_disable_committers_approval: false)
project.update!(merge_requests_disable_committers_approval: false)
expect(merge_request.can_approve?(user)).to be true
end
it 'return false when committers cannot approve' do
project.update(merge_requests_disable_committers_approval: true)
project.update!(merge_requests_disable_committers_approval: true)
expect(merge_request.can_approve?(user)).to be false
end
......@@ -125,7 +125,7 @@ describe ApprovableForRule do
context 'when approvals are required' do
before do
project.update(approvals_before_merge: 1)
project.update!(approvals_before_merge: 1)
end
it 'returns true when approvals are still accepted and user still has not approved' do
......
......@@ -43,8 +43,10 @@ describe ApprovalState do
before do
allow(merge_request).to receive(:committers).and_return(User.where(id: committers))
project.update(merge_requests_author_approval: merge_requests_author_approval)
project.update(merge_requests_disable_committers_approval: merge_requests_disable_committers_approval)
project.update!(
merge_requests_author_approval: merge_requests_author_approval,
merge_requests_disable_committers_approval: merge_requests_disable_committers_approval
)
create_rule(users: committers)
end
......@@ -162,7 +164,7 @@ describe ApprovalState do
context 'when overall approvals required is not zero' do
before do
project.update(approvals_before_merge: 1)
project.update!(approvals_before_merge: 1)
end
it 'returns true' do
......@@ -226,7 +228,7 @@ describe ApprovalState do
shared_examples_for 'checking fallback_approvals_required' do
before do
project.update(approvals_before_merge: 1)
project.update!(approvals_before_merge: 1)
end
context 'when it is not met' do
......@@ -259,7 +261,7 @@ describe ApprovalState do
context 'when regular rules present' do
before do
project.update(approvals_before_merge: 999)
project.update!(approvals_before_merge: 999)
2.times { create_rule(users: [create(:user)]) }
end
......@@ -810,7 +812,7 @@ describe ApprovalState do
describe '#authors_can_approve?' do
context 'when project allows author approval' do
before do
project.update(merge_requests_author_approval: true)
project.update!(merge_requests_author_approval: true)
end
it 'returns true' do
......@@ -820,7 +822,7 @@ describe ApprovalState do
context 'when project disallows author approval' do
before do
project.update(merge_requests_author_approval: false)
project.update!(merge_requests_author_approval: false)
end
it 'returns true' do
......@@ -892,7 +894,7 @@ describe ApprovalState do
context 'when overall approvals required is not zero' do
before do
project.update(approvals_before_merge: 1)
project.update!(approvals_before_merge: 1)
end
it 'returns true' do
......@@ -948,7 +950,7 @@ describe ApprovalState do
shared_examples_for 'checking fallback_approvals_required' do
before do
project.update(approvals_before_merge: 1)
project.update!(approvals_before_merge: 1)
end
context 'when it is not met' do
......@@ -982,7 +984,7 @@ describe ApprovalState do
context 'when regular rules present' do
before do
project.update(approvals_before_merge: 999)
project.update!(approvals_before_merge: 999)
2.times { create_rule(users: [create(:user)]) }
end
......@@ -1369,7 +1371,7 @@ describe ApprovalState do
describe '#authors_can_approve?' do
context 'when project allows author approval' do
before do
project.update(merge_requests_author_approval: true)
project.update!(merge_requests_author_approval: true)
end
it 'returns true' do
......@@ -1379,7 +1381,7 @@ describe ApprovalState do
context 'when project disallows author approval' do
before do
project.update(merge_requests_author_approval: false)
project.update!(merge_requests_author_approval: false)
end
it 'returns true' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment