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/design_management | |
parent | 00b35af3db1abfe813a778f643dad221aad51fca (diff) |
Add latest changes from gitlab-org/gitlab@13-1-stable-ee
Diffstat (limited to 'spec/services/design_management')
-rw-r--r-- | spec/services/design_management/delete_designs_service_spec.rb | 26 | ||||
-rw-r--r-- | spec/services/design_management/save_designs_service_spec.rb | 25 |
2 files changed, 42 insertions, 9 deletions
diff --git a/spec/services/design_management/delete_designs_service_spec.rb b/spec/services/design_management/delete_designs_service_spec.rb index 2c0c1570cb4..bf5d6b443e6 100644 --- a/spec/services/design_management/delete_designs_service_spec.rb +++ b/spec/services/design_management/delete_designs_service_spec.rb @@ -56,6 +56,10 @@ describe DesignManagement::DeleteDesignsService do let(:enabled) { false } it_behaves_like "a service error" + + it 'does not create any events in the activity stream' do + expect { run_service rescue nil }.not_to change { Event.count } + end end context "when the feature is available" do @@ -72,7 +76,9 @@ describe DesignManagement::DeleteDesignsService do it 'does not log any events' do counter = ::Gitlab::UsageDataCounters::DesignsCounter - expect { run_service rescue nil }.not_to change { counter.totals } + + expect { run_service rescue nil } + .not_to change { [counter.totals, Event.count] } end end @@ -92,6 +98,12 @@ describe DesignManagement::DeleteDesignsService do expect { run_service }.to change { counter.read(:delete) }.by(1) end + it 'creates an event in the activity stream' do + expect { run_service } + .to change { Event.count }.by(1) + .and change { Event.destroyed_action.for_design.count }.by(1) + end + it 'informs the new-version-worker' do expect(::DesignManagement::NewVersionWorker).to receive(:perform_async).with(Integer) @@ -129,14 +141,14 @@ describe DesignManagement::DeleteDesignsService do let!(:designs) { create_designs(2) } - it 'removes those designs' do + it 'makes the correct changes' do + counter = ::Gitlab::UsageDataCounters::DesignsCounter + expect { run_service } .to change { issue.designs.current.count }.from(3).to(1) - end - - it 'logs the correct number of deletion events' do - counter = ::Gitlab::UsageDataCounters::DesignsCounter - expect { run_service }.to change { counter.read(:delete) }.by(2) + .and change { counter.read(:delete) }.by(2) + .and change { Event.count }.by(2) + .and change { Event.destroyed_action.for_design.count }.by(2) end it_behaves_like "a success" diff --git a/spec/services/design_management/save_designs_service_spec.rb b/spec/services/design_management/save_designs_service_spec.rb index 013d5473860..3be3ac9daca 100644 --- a/spec/services/design_management/save_designs_service_spec.rb +++ b/spec/services/design_management/save_designs_service_spec.rb @@ -65,6 +65,10 @@ describe DesignManagement::SaveDesignsService do end it_behaves_like 'a service error' + + it 'does not create an event in the activity stream' do + expect { run_service }.not_to change { Event.count } + end end context 'when the feature is available' do @@ -89,6 +93,12 @@ describe DesignManagement::SaveDesignsService do expect { run_service }.to change { counter.read(:create) }.by(1) end + it 'creates an event in the activity stream' do + expect { run_service } + .to change { Event.count }.by(1) + .and change { Event.for_design.created_action.count }.by(1) + end + it 'creates a commit in the repository' do run_service @@ -166,9 +176,12 @@ describe DesignManagement::SaveDesignsService do expect(updated_designs.first.versions.size).to eq(2) end - it 'increments the update counter' do + it 'records the correct events' do counter = Gitlab::UsageDataCounters::DesignsCounter - expect { run_service }.to change { counter.read(:update) }.by 1 + expect { run_service } + .to change { counter.read(:update) }.by(1) + .and change { Event.count }.by(1) + .and change { Event.for_design.updated_action.count }.by(1) end context 'when uploading a new design' do @@ -217,6 +230,14 @@ describe DesignManagement::SaveDesignsService do .and change { counter.read(:update) }.by(1) end + it 'creates the correct activity stream events' do + expect { run_service } + .to change { Event.count }.by(2) + .and change { Event.for_design.count }.by(2) + .and change { Event.created_action.count }.by(1) + .and change { Event.updated_action.count }.by(1) + end + it 'creates a single commit' do commit_count = -> do design_repository.expire_all_method_caches |