diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 14:18:50 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 14:18:50 +0300 |
commit | 8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781 (patch) | |
tree | a77e7fe7a93de11213032ed4ab1f33a3db51b738 /spec/services/resource_events | |
parent | 00b35af3db1abfe813a778f643dad221aad51fca (diff) |
Add latest changes from gitlab-org/gitlab@13-1-stable-ee
Diffstat (limited to 'spec/services/resource_events')
-rw-r--r-- | spec/services/resource_events/change_state_service_spec.rb | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/spec/services/resource_events/change_state_service_spec.rb b/spec/services/resource_events/change_state_service_spec.rb new file mode 100644 index 00000000000..e5d2a4ab11e --- /dev/null +++ b/spec/services/resource_events/change_state_service_spec.rb @@ -0,0 +1,39 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe ResourceEvents::ChangeStateService do + let_it_be(:project) { create(:project) } + let_it_be(:user) { create(:user) } + + let(:issue) { create(:issue, project: project) } + let(:merge_request) { create(:merge_request, source_project: project) } + + describe '#execute' do + context 'when resource is an issue' do + %w[opened reopened closed locked].each do |state| + it "creates the expected event if issue has #{state} state" do + described_class.new(user: user, resource: issue).execute(state) + + event = issue.resource_state_events.last + expect(event.issue).to eq(issue) + expect(event.merge_request).to be_nil + expect(event.state).to eq(state) + end + end + end + + context 'when resource is a merge request' do + %w[opened reopened closed locked merged].each do |state| + it "creates the expected event if merge request has #{state} state" do + described_class.new(user: user, resource: merge_request).execute(state) + + event = merge_request.resource_state_events.last + expect(event.issue).to be_nil + expect(event.merge_request).to eq(merge_request) + expect(event.state).to eq(state) + end + end + end + end +end |