diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-02-17 15:59:25 +0100 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-03-17 07:39:15 +0100 |
commit | c8e7d1ed8e3eafcc8234a0e6f443bf85369c8de1 (patch) | |
tree | 1b6e5cff95e648f2650b8bc7d062585ea637eead /spec/services | |
parent | 11f817b3fda3f77da5fdfda787816fd36d4d98a6 (diff) | |
download | gitlab-ce-c8e7d1ed8e3eafcc8234a0e6f443bf85369c8de1.tar.gz |
Add issue move implementation to controller
Diffstat (limited to 'spec/services')
-rw-r--r-- | spec/services/issues/move_service_spec.rb | 38 | ||||
-rw-r--r-- | spec/services/system_note_service_spec.rb | 2 |
2 files changed, 29 insertions, 11 deletions
diff --git a/spec/services/issues/move_service_spec.rb b/spec/services/issues/move_service_spec.rb index 569e155e617..412a817208e 100644 --- a/spec/services/issues/move_service_spec.rb +++ b/spec/services/issues/move_service_spec.rb @@ -5,26 +5,44 @@ describe Issues::MoveService, services: true do let(:issue) { create(:issue, title: 'Some issue', description: 'Some issue description') } let(:current_project) { issue.project } let(:new_project) { create(:project) } + let(:move_params) { { 'move_to_project_id' => new_project.id } } + let(:move_service) { described_class.new(current_project, user, move_params, issue) } before do current_project.team << [user, :master] end - describe '#execute' do - let!(:new_issue) do - described_class.new(current_project, user).execute(issue, new_project) + context 'issue movable' do + describe '#move?' do + subject { move_service.move? } + it { is_expected.to be_truthy } end - it 'should create a new issue in a new project' do - expect(new_issue.project).to eq new_project - end + describe '#execute' do + let!(:new_issue) { move_service.execute } + + it 'should create a new issue in a new project' do + expect(new_issue.project).to eq new_project + end + + it 'should add system note to old issue' do + expect(issue.notes.last.note).to match /^Moved to/ + end - it 'should add system note to old issue' do - expect(issue.notes.last.note).to match /^Moved to/ + it 'should add system note to new issue' do + expect(new_issue.notes.last.note).to match /^Moved from/ + end end + end + + context 'issue not movable' do + context 'move not requested' do + let(:move_params) { {} } - it 'should add system note to new issue' do - expect(new_issue.notes.last.note).to match /^Moved from/ + describe '#move?' do + subject { move_service.move? } + it { is_expected.to be_falsey } + end end end end diff --git a/spec/services/system_note_service_spec.rb b/spec/services/system_note_service_spec.rb index e0ae49ab37c..7efb9f2ddba 100644 --- a/spec/services/system_note_service_spec.rb +++ b/spec/services/system_note_service_spec.rb @@ -486,7 +486,7 @@ describe SystemNoteService, services: true do end context 'invalid direction' do - let (:direction) { :invalid } + let(:direction) { :invalid } it 'should raise error' do expect { subject }.to raise_error StandardError, /Invalid direction/ |