summaryrefslogtreecommitdiff
path: root/spec/support/shared_examples/services
diff options
context:
space:
mode:
Diffstat (limited to 'spec/support/shared_examples/services')
-rw-r--r--spec/support/shared_examples/services/alert_management/alert_processing/alert_firing_shared_examples.rb4
-rw-r--r--spec/support/shared_examples/services/alert_management/alert_processing/incident_resolution_shared_examples.rb2
-rw-r--r--spec/support/shared_examples/services/alert_management/alert_processing/system_notes_shared_examples.rb4
-rw-r--r--spec/support/shared_examples/services/alert_management_shared_examples.rb4
-rw-r--r--spec/support/shared_examples/services/approval_state_updated_trigger_shared_examples.rb17
-rw-r--r--spec/support/shared_examples/services/boards/boards_create_service_shared_examples.rb4
-rw-r--r--spec/support/shared_examples/services/boards/boards_list_service_shared_examples.rb2
-rw-r--r--spec/support/shared_examples/services/boards/boards_recent_visit_shared_examples.rb2
-rw-r--r--spec/support/shared_examples/services/boards/lists_destroy_service_shared_examples.rb4
-rw-r--r--spec/support/shared_examples/services/boards/lists_list_service_shared_examples.rb6
-rw-r--r--spec/support/shared_examples/services/container_expiration_policy_shared_examples.rb2
-rw-r--r--spec/support/shared_examples/services/dependency_proxy_ttl_policies_shared_examples.rb2
-rw-r--r--spec/support/shared_examples/services/incident_shared_examples.rb4
-rw-r--r--spec/support/shared_examples/services/issuable/update_service_shared_examples.rb8
-rw-r--r--spec/support/shared_examples/services/issuable_links/create_links_shared_examples.rb8
-rw-r--r--spec/support/shared_examples/services/issuable_links/destroyable_issuable_links_shared_examples.rb4
-rw-r--r--spec/support/shared_examples/services/namespace_package_settings_shared_examples.rb2
-rw-r--r--spec/support/shared_examples/services/packages_shared_examples.rb14
-rw-r--r--spec/support/shared_examples/services/projects/update_repository_storage_service_shared_examples.rb6
-rw-r--r--spec/support/shared_examples/services/repositories/housekeeping_shared_examples.rb47
-rw-r--r--spec/support/shared_examples/services/schedule_bulk_repository_shard_moves_shared_examples.rb4
-rw-r--r--spec/support/shared_examples/services/snowplow_tracking_shared_examples.rb2
-rw-r--r--spec/support/shared_examples/services/timelogs/create_service_shared_examples.rb47
-rw-r--r--spec/support/shared_examples/services/users/build_service_shared_examples.rb10
-rw-r--r--spec/support/shared_examples/services/wiki_pages/create_service_shared_examples.rb2
-rw-r--r--spec/support/shared_examples/services/wiki_pages/update_service_shared_examples.rb2
-rw-r--r--spec/support/shared_examples/services/work_items/widgets/milestone_service_shared_examples.rb4
27 files changed, 153 insertions, 64 deletions
diff --git a/spec/support/shared_examples/services/alert_management/alert_processing/alert_firing_shared_examples.rb b/spec/support/shared_examples/services/alert_management/alert_processing/alert_firing_shared_examples.rb
index 0db9519f760..6a9da91eaa7 100644
--- a/spec/support/shared_examples/services/alert_management/alert_processing/alert_firing_shared_examples.rb
+++ b/spec/support/shared_examples/services/alert_management/alert_processing/alert_firing_shared_examples.rb
@@ -11,7 +11,7 @@ RSpec.shared_examples 'creates an alert management alert or errors' do
it 'creates AlertManagement::Alert' do
expect(Gitlab::AppLogger).not_to receive(:warn)
- expect { subject }.to change(AlertManagement::Alert, :count).by(1)
+ expect { subject }.to change { AlertManagement::Alert.count }.by(1)
end
it 'executes the alert service hooks' do
@@ -118,7 +118,7 @@ end
RSpec.shared_examples 'does not create an alert management alert' do
specify do
- expect { subject }.not_to change(AlertManagement::Alert, :count)
+ expect { subject }.not_to change { AlertManagement::Alert.count }
end
end
diff --git a/spec/support/shared_examples/services/alert_management/alert_processing/incident_resolution_shared_examples.rb b/spec/support/shared_examples/services/alert_management/alert_processing/incident_resolution_shared_examples.rb
index 1973577d742..2740b6bf59d 100644
--- a/spec/support/shared_examples/services/alert_management/alert_processing/incident_resolution_shared_examples.rb
+++ b/spec/support/shared_examples/services/alert_management/alert_processing/incident_resolution_shared_examples.rb
@@ -14,7 +14,7 @@ RSpec.shared_examples 'closes related incident if enabled' do
specify do
expect { Sidekiq::Testing.inline! { subject } }
.to change { alert.issue.reload.closed? }.from(false).to(true)
- .and change(ResourceStateEvent, :count).by(1)
+ .and change { ResourceStateEvent.count }.by(1)
end
end
diff --git a/spec/support/shared_examples/services/alert_management/alert_processing/system_notes_shared_examples.rb b/spec/support/shared_examples/services/alert_management/alert_processing/system_notes_shared_examples.rb
index 57d598c0259..2d0815ba27c 100644
--- a/spec/support/shared_examples/services/alert_management/alert_processing/system_notes_shared_examples.rb
+++ b/spec/support/shared_examples/services/alert_management/alert_processing/system_notes_shared_examples.rb
@@ -19,7 +19,7 @@ RSpec.shared_examples 'creates expected system notes for alert' do |*notes|
end
it "for #{notes.join(', ')}" do
- expect { subject }.to change(Note, :count).by(expected_note_count)
+ expect { subject }.to change { Note.count }.by(expected_note_count)
expected_notes.each_value.with_index do |value, index|
expect(new_notes[index]).to include(value)
@@ -29,6 +29,6 @@ end
RSpec.shared_examples 'does not create a system note for alert' do
specify do
- expect { subject }.not_to change(Note, :count)
+ expect { subject }.not_to change { Note.count }
end
end
diff --git a/spec/support/shared_examples/services/alert_management_shared_examples.rb b/spec/support/shared_examples/services/alert_management_shared_examples.rb
index b46ace1824a..b8fc2eb5475 100644
--- a/spec/support/shared_examples/services/alert_management_shared_examples.rb
+++ b/spec/support/shared_examples/services/alert_management_shared_examples.rb
@@ -68,8 +68,8 @@ RSpec.shared_examples 'processes one firing and one resolved prometheus alerts'
expect(Gitlab::AppLogger).not_to receive(:warn)
expect { subject }
- .to change(AlertManagement::Alert, :count).by(1)
- .and change(Note, :count).by(1)
+ .to change { AlertManagement::Alert.count }.by(1)
+ .and change { Note.count }.by(1)
expect(subject).to be_success
expect(subject.payload).to eq({})
diff --git a/spec/support/shared_examples/services/approval_state_updated_trigger_shared_examples.rb b/spec/support/shared_examples/services/approval_state_updated_trigger_shared_examples.rb
new file mode 100644
index 00000000000..455fd308be8
--- /dev/null
+++ b/spec/support/shared_examples/services/approval_state_updated_trigger_shared_examples.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+RSpec.shared_examples 'triggers GraphQL subscription mergeRequestApprovalStateUpdated' do
+ specify do
+ expect(GraphqlTriggers).to receive(:merge_request_approval_state_updated).with(merge_request)
+
+ action
+ end
+end
+
+RSpec.shared_examples 'does not trigger GraphQL subscription mergeRequestApprovalStateUpdated' do
+ specify do
+ expect(GraphqlTriggers).not_to receive(:merge_request_approval_state_updated)
+
+ action
+ end
+end
diff --git a/spec/support/shared_examples/services/boards/boards_create_service_shared_examples.rb b/spec/support/shared_examples/services/boards/boards_create_service_shared_examples.rb
index f28c78aec97..67a5af587e9 100644
--- a/spec/support/shared_examples/services/boards/boards_create_service_shared_examples.rb
+++ b/spec/support/shared_examples/services/boards/boards_create_service_shared_examples.rb
@@ -3,7 +3,7 @@
RSpec.shared_examples 'boards create service' do
context 'when parent does not have a board' do
it 'creates a new board' do
- expect { service.execute }.to change(Board, :count).by(1)
+ expect { service.execute }.to change { Board.count }.by(1)
end
it 'creates the default lists' do
@@ -23,7 +23,7 @@ RSpec.shared_examples 'boards create service' do
it 'does not create a new board' do
expect(service).to receive(:can_create_board?) { false }
- expect { service.execute }.not_to change(parent.boards, :count)
+ expect { service.execute }.not_to change { parent.boards.count }
end
end
end
diff --git a/spec/support/shared_examples/services/boards/boards_list_service_shared_examples.rb b/spec/support/shared_examples/services/boards/boards_list_service_shared_examples.rb
index fd832d4484d..80d5c771abd 100644
--- a/spec/support/shared_examples/services/boards/boards_list_service_shared_examples.rb
+++ b/spec/support/shared_examples/services/boards/boards_list_service_shared_examples.rb
@@ -2,7 +2,7 @@
RSpec.shared_examples 'boards list service' do
it 'does not create a new board' do
- expect { service.execute }.not_to change(parent.boards, :count)
+ expect { service.execute }.not_to change { parent.boards.count }
end
it 'returns parent boards' do
diff --git a/spec/support/shared_examples/services/boards/boards_recent_visit_shared_examples.rb b/spec/support/shared_examples/services/boards/boards_recent_visit_shared_examples.rb
index 68ea460dabc..8bf01ad84ff 100644
--- a/spec/support/shared_examples/services/boards/boards_recent_visit_shared_examples.rb
+++ b/spec/support/shared_examples/services/boards/boards_recent_visit_shared_examples.rb
@@ -5,7 +5,7 @@ RSpec.shared_examples 'boards recent visit' do
describe '#visited' do
it 'creates a visit if one does not exists' do
- expect { described_class.visited!(user, board) }.to change(described_class, :count).by(1)
+ expect { described_class.visited!(user, board) }.to change { described_class.count }.by(1)
end
shared_examples 'was visited previously' do
diff --git a/spec/support/shared_examples/services/boards/lists_destroy_service_shared_examples.rb b/spec/support/shared_examples/services/boards/lists_destroy_service_shared_examples.rb
index af88644ced7..52d427d6684 100644
--- a/spec/support/shared_examples/services/boards/lists_destroy_service_shared_examples.rb
+++ b/spec/support/shared_examples/services/boards/lists_destroy_service_shared_examples.rb
@@ -5,7 +5,7 @@ RSpec.shared_examples 'lists destroy service' do
it 'removes list from board' do
service = described_class.new(parent, user)
- expect { service.execute(list) }.to change(board.lists, :count).by(-1)
+ expect { service.execute(list) }.to change { board.lists.count }.by(-1)
end
it 'decrements position of higher lists' do
@@ -24,6 +24,6 @@ RSpec.shared_examples 'lists destroy service' do
it 'does not remove list from board when list type is closed' do
service = described_class.new(parent, user)
- expect { service.execute(closed_list) }.not_to change(board.lists, :count)
+ expect { service.execute(closed_list) }.not_to change { board.lists.count }
end
end
diff --git a/spec/support/shared_examples/services/boards/lists_list_service_shared_examples.rb b/spec/support/shared_examples/services/boards/lists_list_service_shared_examples.rb
index e1143562661..b9f28fab558 100644
--- a/spec/support/shared_examples/services/boards/lists_list_service_shared_examples.rb
+++ b/spec/support/shared_examples/services/boards/lists_list_service_shared_examples.rb
@@ -5,7 +5,7 @@ RSpec.shared_examples 'lists list service' do
let!(:backlog_list) { create_backlog_list(board) }
it 'does not create a backlog list' do
- expect { service.execute(board) }.not_to change(board.lists, :count)
+ expect { service.execute(board) }.not_to change { board.lists.count }
end
it "returns board's lists" do
@@ -35,11 +35,11 @@ RSpec.shared_examples 'lists list service' do
context 'when the board does not have a backlog list' do
it 'creates a backlog list' do
- expect { service.execute(board) }.to change(board.lists, :count).by(1)
+ expect { service.execute(board) }.to change { board.lists.count }.by(1)
end
it 'does not create a backlog list when create_default_lists is false' do
- expect { service.execute(board, create_default_lists: false) }.not_to change(board.lists, :count)
+ expect { service.execute(board, create_default_lists: false) }.not_to change { board.lists.count }
end
it "returns board's lists" do
diff --git a/spec/support/shared_examples/services/container_expiration_policy_shared_examples.rb b/spec/support/shared_examples/services/container_expiration_policy_shared_examples.rb
index 28bf46a57d5..38e19e58706 100644
--- a/spec/support/shared_examples/services/container_expiration_policy_shared_examples.rb
+++ b/spec/support/shared_examples/services/container_expiration_policy_shared_examples.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-RSpec.shared_examples 'updating the container expiration policy attributes' do |mode:, from: {}, to:|
+RSpec.shared_examples 'updating the container expiration policy attributes' do |mode:, to:, from: {}|
if mode == :create
it 'creates a new container expiration policy' do
expect { subject }
diff --git a/spec/support/shared_examples/services/dependency_proxy_ttl_policies_shared_examples.rb b/spec/support/shared_examples/services/dependency_proxy_ttl_policies_shared_examples.rb
index f6692646ca8..dcc9c3d898f 100644
--- a/spec/support/shared_examples/services/dependency_proxy_ttl_policies_shared_examples.rb
+++ b/spec/support/shared_examples/services/dependency_proxy_ttl_policies_shared_examples.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-RSpec.shared_examples 'updating the dependency proxy image ttl policy attributes' do |from: {}, to:|
+RSpec.shared_examples 'updating the dependency proxy image ttl policy attributes' do |to:, from: {}|
it_behaves_like 'not creating the dependency proxy image ttl policy'
it 'updates the dependency proxy image ttl policy' do
diff --git a/spec/support/shared_examples/services/incident_shared_examples.rb b/spec/support/shared_examples/services/incident_shared_examples.rb
index b533b095aac..a87e7c1f801 100644
--- a/spec/support/shared_examples/services/incident_shared_examples.rb
+++ b/spec/support/shared_examples/services/incident_shared_examples.rb
@@ -55,7 +55,7 @@ RSpec.shared_examples 'incident management label service' do
shared_examples 'existing label' do
it 'returns the existing label' do
- expect { execute }.not_to change(Label, :count)
+ expect { execute }.not_to change { Label.count }
expect(execute).to be_success
expect(execute.payload).to eq(label: label)
@@ -64,7 +64,7 @@ RSpec.shared_examples 'incident management label service' do
shared_examples 'new label' do
it 'creates a new label' do
- expect { execute }.to change(Label, :count).by(1)
+ expect { execute }.to change { Label.count }.by(1)
label = project.reload.labels.last
expect(execute).to be_success
diff --git a/spec/support/shared_examples/services/issuable/update_service_shared_examples.rb b/spec/support/shared_examples/services/issuable/update_service_shared_examples.rb
index 3d90885dd6f..ff7acc7e907 100644
--- a/spec/support/shared_examples/services/issuable/update_service_shared_examples.rb
+++ b/spec/support/shared_examples/services/issuable/update_service_shared_examples.rb
@@ -5,7 +5,7 @@ RSpec.shared_examples_for 'issuable update service updating last_edited_at value
let(:update_params) { { title: 'updated title' } }
it 'does not update last_edited values' do
- expect { update_issuable }.to change(issuable, :title).from(issuable.title).to('updated title').and(
+ expect { update_issuable }.to change { issuable.title }.from(issuable.title).to('updated title').and(
not_change(issuable, :last_edited_at)
).and(
not_change(issuable, :last_edited_by)
@@ -19,10 +19,10 @@ RSpec.shared_examples_for 'issuable update service updating last_edited_at value
it 'updates last_edited values' do
expect do
update_issuable
- end.to change(issuable, :description).from(issuable.description).to('updated description').and(
- change(issuable, :last_edited_at)
+ end.to change { issuable.description }.from(issuable.description).to('updated description').and(
+ change { issuable.last_edited_at }
).and(
- change(issuable, :last_edited_by)
+ change { issuable.last_edited_by }
)
end
end
diff --git a/spec/support/shared_examples/services/issuable_links/create_links_shared_examples.rb b/spec/support/shared_examples/services/issuable_links/create_links_shared_examples.rb
index 65351ac94ab..12f2b5d78a5 100644
--- a/spec/support/shared_examples/services/issuable_links/create_links_shared_examples.rb
+++ b/spec/support/shared_examples/services/issuable_links/create_links_shared_examples.rb
@@ -24,7 +24,7 @@ RSpec.shared_examples 'issuable link creation' do
end
it 'no relationship is created' do
- expect { subject }.not_to change(issuable_link_class, :count)
+ expect { subject }.not_to change { issuable_link_class.count }
end
end
@@ -38,7 +38,7 @@ RSpec.shared_examples 'issuable link creation' do
end
it 'no relationship is created' do
- expect { subject }.not_to change(issuable_link_class, :count)
+ expect { subject }.not_to change { issuable_link_class.count }
end
end
@@ -54,7 +54,7 @@ RSpec.shared_examples 'issuable link creation' do
end
it 'no relationship is created' do
- expect { subject }.not_to change(issuable_link_class, :count)
+ expect { subject }.not_to change { issuable_link_class.count }
end
end
@@ -64,7 +64,7 @@ RSpec.shared_examples 'issuable link creation' do
end
it 'creates relationships' do
- expect { subject }.to change(issuable_link_class, :count).by(2)
+ expect { subject }.to change { issuable_link_class.count }.by(2)
expect(issuable_link_class.find_by!(target: issuable2)).to have_attributes(source: issuable, link_type: 'relates_to')
expect(issuable_link_class.find_by!(target: issuable3)).to have_attributes(source: issuable, link_type: 'relates_to')
diff --git a/spec/support/shared_examples/services/issuable_links/destroyable_issuable_links_shared_examples.rb b/spec/support/shared_examples/services/issuable_links/destroyable_issuable_links_shared_examples.rb
index 5e80014da1d..cc170c6544d 100644
--- a/spec/support/shared_examples/services/issuable_links/destroyable_issuable_links_shared_examples.rb
+++ b/spec/support/shared_examples/services/issuable_links/destroyable_issuable_links_shared_examples.rb
@@ -8,7 +8,7 @@ RSpec.shared_examples 'a destroyable issuable link' do
end
it 'removes related issue' do
- expect { subject }.to change(issuable_link.class, :count).by(-1)
+ expect { subject }.to change { issuable_link.class.count }.by(-1)
end
it 'creates notes' do
@@ -28,7 +28,7 @@ RSpec.shared_examples 'a destroyable issuable link' do
context 'when failing to remove an issuable link' do
it 'does not remove relation' do
- expect { subject }.not_to change(issuable_link.class, :count).from(1)
+ expect { subject }.not_to change { issuable_link.class.count }.from(1)
end
it 'does not create notes' do
diff --git a/spec/support/shared_examples/services/namespace_package_settings_shared_examples.rb b/spec/support/shared_examples/services/namespace_package_settings_shared_examples.rb
index f7a6bd3676a..11a786fdefb 100644
--- a/spec/support/shared_examples/services/namespace_package_settings_shared_examples.rb
+++ b/spec/support/shared_examples/services/namespace_package_settings_shared_examples.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-RSpec.shared_examples 'updating the namespace package setting attributes' do |from: {}, to:|
+RSpec.shared_examples 'updating the namespace package setting attributes' do |to:, from: {}|
it_behaves_like 'not creating the namespace package setting'
it 'updates the namespace package setting' do
diff --git a/spec/support/shared_examples/services/packages_shared_examples.rb b/spec/support/shared_examples/services/packages_shared_examples.rb
index ca4dea90c55..e0dd08ec50e 100644
--- a/spec/support/shared_examples/services/packages_shared_examples.rb
+++ b/spec/support/shared_examples/services/packages_shared_examples.rb
@@ -188,20 +188,6 @@ RSpec.shared_examples 'returns paginated packages' do
end
end
-RSpec.shared_examples 'background upload schedules a file migration' do
- context 'background upload enabled' do
- before do
- stub_package_file_object_storage(background_upload: true)
- end
-
- it 'schedules migration of file to object storage' do
- expect(ObjectStorage::BackgroundMoveWorker).to receive(:perform_async).with('Packages::PackageFileUploader', 'Packages::PackageFile', :file, kind_of(Numeric))
-
- subject
- end
- end
-end
-
RSpec.shared_context 'package filter context' do
def package_filter_url(filter, param)
"/projects/#{project.id}/packages?package_#{filter}=#{param}"
diff --git a/spec/support/shared_examples/services/projects/update_repository_storage_service_shared_examples.rb b/spec/support/shared_examples/services/projects/update_repository_storage_service_shared_examples.rb
index 14af35e58b7..9f940d27341 100644
--- a/spec/support/shared_examples/services/projects/update_repository_storage_service_shared_examples.rb
+++ b/spec/support/shared_examples/services/projects/update_repository_storage_service_shared_examples.rb
@@ -71,7 +71,7 @@ RSpec.shared_examples 'moves repository to another storage' do |repository_type|
it 'does not enqueue a GC run' do
expect { subject.execute }
- .not_to change(Projects::GitGarbageCollectWorker.jobs, :count)
+ .not_to change { Projects::GitGarbageCollectWorker.jobs.count }
end
end
@@ -84,12 +84,12 @@ RSpec.shared_examples 'moves repository to another storage' do |repository_type|
stub_application_setting(housekeeping_enabled: false)
expect { subject.execute }
- .not_to change(Projects::GitGarbageCollectWorker.jobs, :count)
+ .not_to change { Projects::GitGarbageCollectWorker.jobs.count }
end
it 'enqueues a GC run' do
expect { subject.execute }
- .to change(Projects::GitGarbageCollectWorker.jobs, :count).by(1)
+ .to change { Projects::GitGarbageCollectWorker.jobs.count }.by(1)
end
end
end
diff --git a/spec/support/shared_examples/services/repositories/housekeeping_shared_examples.rb b/spec/support/shared_examples/services/repositories/housekeeping_shared_examples.rb
index 4c00faee56b..8a937303711 100644
--- a/spec/support/shared_examples/services/repositories/housekeeping_shared_examples.rb
+++ b/spec/support/shared_examples/services/repositories/housekeeping_shared_examples.rb
@@ -12,7 +12,7 @@ RSpec.shared_examples 'housekeeps repository' do
expect(resource.git_garbage_collect_worker_klass).to receive(:perform_async).with(resource.id, :incremental_repack, :the_lease_key, :the_uuid).and_call_original
Sidekiq::Testing.fake! do
- expect { subject.execute }.to change(resource.git_garbage_collect_worker_klass.jobs, :size).by(1)
+ expect { subject.execute }.to change { resource.git_garbage_collect_worker_klass.jobs.size }.by(1)
end
end
@@ -71,9 +71,6 @@ RSpec.shared_examples 'housekeeps repository' do
# At push 10, 20, ... (except those above)
expect(resource.git_garbage_collect_worker_klass).to receive(:perform_async).with(resource.id, :incremental_repack, :the_lease_key, :the_uuid)
.exactly(16).times
- # At push 6, 12, 18, ... (except those above)
- expect(resource.git_garbage_collect_worker_klass).to receive(:perform_async).with(resource.id, :pack_refs, :the_lease_key, :the_uuid)
- .exactly(27).times
201.times do
subject.increment!
@@ -82,6 +79,37 @@ RSpec.shared_examples 'housekeeps repository' do
expect(resource.pushes_since_gc).to eq(1)
end
+
+ context 'when optimized_repository feature flag is disabled' do
+ before do
+ stub_feature_flags(optimized_housekeeping: false)
+ end
+
+ it 'calls also the garbage collect worker with pack_refs every 6 commits' do
+ allow(subject).to receive(:try_obtain_lease).and_return(:the_uuid)
+ allow(subject).to receive(:lease_key).and_return(:the_lease_key)
+
+ # At push 200
+ expect(resource.git_garbage_collect_worker_klass).to receive(:perform_async).with(resource.id, :gc, :the_lease_key, :the_uuid)
+ .once
+ # At push 50, 100, 150
+ expect(resource.git_garbage_collect_worker_klass).to receive(:perform_async).with(resource.id, :full_repack, :the_lease_key, :the_uuid)
+ .exactly(3).times
+ # At push 10, 20, ... (except those above)
+ expect(resource.git_garbage_collect_worker_klass).to receive(:perform_async).with(resource.id, :incremental_repack, :the_lease_key, :the_uuid)
+ .exactly(16).times
+ # At push 6, 12, 18, ... (except those above)
+ expect(resource.git_garbage_collect_worker_klass).to receive(:perform_async).with(resource.id, :pack_refs, :the_lease_key, :the_uuid)
+ .exactly(27).times
+
+ 201.times do
+ subject.increment!
+ subject.execute if subject.needed?
+ end
+
+ expect(resource.pushes_since_gc).to eq(1)
+ end
+ end
end
it 'runs the task specifically requested' do
@@ -107,6 +135,17 @@ RSpec.shared_examples 'housekeeps repository' do
allow(resource).to receive(:pushes_since_gc).and_return(10)
expect(subject.needed?).to eq(true)
end
+
+ context 'when optimized_housekeeping is disabled' do
+ before do
+ stub_feature_flags(optimized_housekeeping: false)
+ end
+
+ it 'returns true pack refs is needed' do
+ allow(resource).to receive(:pushes_since_gc).and_return(described_class::PACK_REFS_PERIOD)
+ expect(subject.needed?).to eq(true)
+ end
+ end
end
describe '#increment!' do
diff --git a/spec/support/shared_examples/services/schedule_bulk_repository_shard_moves_shared_examples.rb b/spec/support/shared_examples/services/schedule_bulk_repository_shard_moves_shared_examples.rb
index 97304680316..acf15730180 100644
--- a/spec/support/shared_examples/services/schedule_bulk_repository_shard_moves_shared_examples.rb
+++ b/spec/support/shared_examples/services/schedule_bulk_repository_shard_moves_shared_examples.rb
@@ -11,7 +11,7 @@ RSpec.shared_examples 'moves repository shard in bulk' do
describe '#execute' do
it 'schedules container repository storage moves' do
expect { subject.execute(source_storage_name, destination_storage_name) }
- .to change(move_service_klass, :count).by(1)
+ .to change { move_service_klass.count }.by(1)
storage_move = container.repository_storage_moves.last!
@@ -29,7 +29,7 @@ RSpec.shared_examples 'moves repository shard in bulk' do
expect(subject).to receive(:log_info)
.with(/Container #{container.full_path} \(#{container.id}\) was skipped: #{container.class} is read-only/)
expect { subject.execute(source_storage_name, destination_storage_name) }
- .to change(move_service_klass, :count).by(0)
+ .to change { move_service_klass.count }.by(0)
end
end
end
diff --git a/spec/support/shared_examples/services/snowplow_tracking_shared_examples.rb b/spec/support/shared_examples/services/snowplow_tracking_shared_examples.rb
index 31919a4263d..e72e8e79411 100644
--- a/spec/support/shared_examples/services/snowplow_tracking_shared_examples.rb
+++ b/spec/support/shared_examples/services/snowplow_tracking_shared_examples.rb
@@ -7,5 +7,5 @@ RSpec.shared_examples 'issue_edit snowplow tracking' do
let(:namespace) { project.namespace }
let(:feature_flag_name) { :route_hll_to_snowplow_phase2 }
- it_behaves_like 'Snowplow event tracking'
+ it_behaves_like 'Snowplow event tracking with RedisHLL context'
end
diff --git a/spec/support/shared_examples/services/timelogs/create_service_shared_examples.rb b/spec/support/shared_examples/services/timelogs/create_service_shared_examples.rb
index 53c42ec0e00..00d4224f021 100644
--- a/spec/support/shared_examples/services/timelogs/create_service_shared_examples.rb
+++ b/spec/support/shared_examples/services/timelogs/create_service_shared_examples.rb
@@ -1,6 +1,12 @@
# frozen_string_literal: true
RSpec.shared_examples 'issuable supports timelog creation service' do
+ let_it_be(:time_spent) { 3600 }
+ let_it_be(:spent_at) { Time.now }
+ let_it_be(:summary) { "Test summary" }
+
+ let(:service) { described_class.new(issuable, time_spent, spent_at, summary, user) }
+
shared_examples 'success_response' do
it 'sucessfully saves the timelog' do
is_expected.to be_success
@@ -9,7 +15,7 @@ RSpec.shared_examples 'issuable supports timelog creation service' do
expect(timelog).to be_persisted
expect(timelog.time_spent).to eq(time_spent)
- expect(timelog.spent_at).to eq('Fri, 08 Jul 2022 00:00:00.000000000 UTC +00:00')
+ expect(timelog.spent_at).to eq(spent_at)
expect(timelog.summary).to eq(summary)
expect(timelog.issuable).to eq(issuable)
end
@@ -34,6 +40,39 @@ RSpec.shared_examples 'issuable supports timelog creation service' do
users_container.add_reporter(user)
end
+ context 'when spent_at is in the future' do
+ let_it_be(:spent_at) { Time.now + 2.hours }
+
+ it 'returns an error' do
+ is_expected.to be_error
+
+ expect(subject.message).to eq("Spent at can't be a future date and time.")
+ expect(subject.http_status).to eq(404)
+ end
+ end
+
+ context 'when time_spent is zero' do
+ let_it_be(:time_spent) { 0 }
+
+ it 'returns an error' do
+ is_expected.to be_error
+
+ expect(subject.message).to eq("Time spent can't be zero.")
+ expect(subject.http_status).to eq(404)
+ end
+ end
+
+ context 'when time_spent is nil' do
+ let_it_be(:time_spent) { nil }
+
+ it 'returns an error' do
+ is_expected.to be_error
+
+ expect(subject.message).to eq("Time spent can't be blank")
+ expect(subject.http_status).to eq(404)
+ end
+ end
+
context 'when the timelog save fails' do
before do
allow_next_instance_of(Timelog) do |timelog|
@@ -54,6 +93,12 @@ RSpec.shared_examples 'issuable supports timelog creation service' do
end
RSpec.shared_examples 'issuable does not support timelog creation service' do
+ let_it_be(:time_spent) { 3600 }
+ let_it_be(:spent_at) { Time.now }
+ let_it_be(:summary) { "Test summary" }
+
+ let(:service) { described_class.new(issuable, time_spent, spent_at, summary, user) }
+
shared_examples 'error_response' do
it 'returns an error' do
is_expected.to be_error
diff --git a/spec/support/shared_examples/services/users/build_service_shared_examples.rb b/spec/support/shared_examples/services/users/build_service_shared_examples.rb
index 6a8695e1786..e448f2f874b 100644
--- a/spec/support/shared_examples/services/users/build_service_shared_examples.rb
+++ b/spec/support/shared_examples/services/users/build_service_shared_examples.rb
@@ -84,9 +84,10 @@ RSpec.shared_examples_for 'current user not admin build items' do
end
end
- context 'when "send_user_confirmation_email" application setting is true' do
+ context 'when "email_confirmation_setting" application setting is set to `hard`' do
before do
- stub_application_setting(send_user_confirmation_email: true, signup_enabled?: true)
+ stub_application_setting_enum('email_confirmation_setting', 'hard')
+ stub_application_setting(signup_enabled?: true)
end
it 'does not confirm the user' do
@@ -94,9 +95,10 @@ RSpec.shared_examples_for 'current user not admin build items' do
end
end
- context 'when "send_user_confirmation_email" application setting is false' do
+ context 'when "email_confirmation_setting" application setting is set to `off`' do
before do
- stub_application_setting(send_user_confirmation_email: false, signup_enabled?: true)
+ stub_application_setting_enum('email_confirmation_setting', 'off')
+ stub_application_setting(signup_enabled?: true)
end
it 'confirms the user' do
diff --git a/spec/support/shared_examples/services/wiki_pages/create_service_shared_examples.rb b/spec/support/shared_examples/services/wiki_pages/create_service_shared_examples.rb
index 980a752cf86..ced49b3e481 100644
--- a/spec/support/shared_examples/services/wiki_pages/create_service_shared_examples.rb
+++ b/spec/support/shared_examples/services/wiki_pages/create_service_shared_examples.rb
@@ -75,7 +75,7 @@ RSpec.shared_examples 'WikiPages::CreateService#execute' do |container_type|
end
it 'does not record the activity' do
- expect { service.execute }.not_to change(Event, :count)
+ expect { service.execute }.not_to change { Event.count }
end
it 'reports the error' do
diff --git a/spec/support/shared_examples/services/wiki_pages/update_service_shared_examples.rb b/spec/support/shared_examples/services/wiki_pages/update_service_shared_examples.rb
index fd10dd4367e..5511843e681 100644
--- a/spec/support/shared_examples/services/wiki_pages/update_service_shared_examples.rb
+++ b/spec/support/shared_examples/services/wiki_pages/update_service_shared_examples.rb
@@ -79,7 +79,7 @@ RSpec.shared_examples 'WikiPages::UpdateService#execute' do |container_type|
end
it 'does not record the activity' do
- expect { service.execute page }.not_to change(Event, :count)
+ expect { service.execute page }.not_to change { Event.count }
end
it 'reports the error' do
diff --git a/spec/support/shared_examples/services/work_items/widgets/milestone_service_shared_examples.rb b/spec/support/shared_examples/services/work_items/widgets/milestone_service_shared_examples.rb
index ac17915c15a..ac064ed4c33 100644
--- a/spec/support/shared_examples/services/work_items/widgets/milestone_service_shared_examples.rb
+++ b/spec/support/shared_examples/services/work_items/widgets/milestone_service_shared_examples.rb
@@ -23,7 +23,7 @@ RSpec.shared_examples "setting work item's milestone" do
it "sets the work item's milestone" do
expect { execute_callback }
- .to change(work_item, :milestone)
+ .to change { work_item.milestone }
.from(nil)
.to(group_milestone)
end
@@ -34,7 +34,7 @@ RSpec.shared_examples "setting work item's milestone" do
it "sets the work item's milestone" do
expect { execute_callback }
- .to change(work_item, :milestone)
+ .to change { work_item.milestone }
.from(nil)
.to(project_milestone)
end