fix pull requests api specs

This commit is contained in:
Alexander Machehin 2015-05-11 13:27:33 +05:00
parent 7f5a8c527b
commit 0f004ea91f
1 changed files with 4 additions and 11 deletions

View File

@ -294,33 +294,26 @@ describe Api::V1::PullRequestsController, type: :controller do
ActionMailer::Base.deliveries = [] ActionMailer::Base.deliveries = []
end end
it 'should send two email messages to project admins' do it 'should send two email messages to all project members' do
post :create, @create_params post :create, @create_params
# @project.pull_requests.last.issue.send(:new_issue_notifications) expect(ActionMailer::Base.deliveries.count).to eq 3 # project owner + reader + admin
# @project.pull_requests.last.issue.send(:send_assign_notifications)
expect(ActionMailer::Base.deliveries.count).to eq 2
end end
it 'should send two email messages to admins and one to assignee' do it 'should send two email messages to admins and one to assignee' do
post :create, @create_params.deep_merge(pull_request: {assignee_id: @project_reader.id}) post :create, @create_params.deep_merge(pull_request: {assignee_id: @project_reader.id})
# @project.pull_requests.last.issue.send(:new_issue_notifications)
# @project.pull_requests.last.issue.send(:send_assign_notifications)
expect(ActionMailer::Base.deliveries.count).to eq 3 expect(ActionMailer::Base.deliveries.count).to eq 3
end end
it 'should send email message to new assignee' do it 'should send email message to new assignee' do
http_login(@project_admin) http_login(@project_admin)
put :update, @update_params.deep_merge(pull_request: {assignee_id: @project_reader.id}) put :update, @update_params.deep_merge(pull_request: {assignee_id: @project_reader.id})
# @project.pull_requests.last.issue.send(:send_assign_notifications)
expect(ActionMailer::Base.deliveries.count).to eq 1 expect(ActionMailer::Base.deliveries.count).to eq 1
end end
it 'should not duplicate email message' do it 'should not duplicate email message' do
post :create, @create_params.deep_merge(pull_request: {assignee_id: @project_admin.id}) post :create, @create_params.deep_merge(pull_request: {assignee_id: @project_admin.id})
# @project.pull_requests.last.issue.send(:new_issue_notifications) expect(ActionMailer::Base.deliveries.count).to eq 2 # send to all project members
# @project.pull_requests.last.issue.send(:send_assign_notifications) expect(ActionMailer::Base.deliveries.map(&:to).uniq).to match_array(ActionMailer::Base.deliveries.map(&:to))
expect(ActionMailer::Base.deliveries.count).to eq 2 # send only to admins
expect(ActionMailer::Base.deliveries.first.to).to_not eq ActionMailer::Base.deliveries.last.to
end end
end end