Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/support/shared_examples/services')
-rw-r--r--spec/support/shared_examples/services/container_expiration_policy_shared_examples.rb40
-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/destroy_service_shared_examples.rb2
-rw-r--r--spec/support/shared_examples/services/wiki_pages/update_service_shared_examples.rb2
4 files changed, 43 insertions, 3 deletions
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
new file mode 100644
index 00000000000..28bf46a57d5
--- /dev/null
+++ b/spec/support/shared_examples/services/container_expiration_policy_shared_examples.rb
@@ -0,0 +1,40 @@
+# frozen_string_literal: true
+
+RSpec.shared_examples 'updating the container expiration policy attributes' do |mode:, from: {}, to:|
+ if mode == :create
+ it 'creates a new container expiration policy' do
+ expect { subject }
+ .to change { project.reload.container_expiration_policy.present? }.from(false).to(true)
+ .and change { ContainerExpirationPolicy.count }.by(1)
+ end
+ else
+ it_behaves_like 'not creating the container expiration policy'
+ end
+
+ it 'updates the container expiration policy' do
+ if from.empty?
+ subject
+
+ expect(container_expiration_policy.reload.cadence).to eq(to[:cadence])
+ expect(container_expiration_policy.keep_n).to eq(to[:keep_n])
+ expect(container_expiration_policy.older_than).to eq(to[:older_than])
+ else
+ expect { subject }
+ .to change { container_expiration_policy.reload.cadence }.from(from[:cadence]).to(to[:cadence])
+ .and change { container_expiration_policy.reload.keep_n }.from(from[:keep_n]).to(to[:keep_n])
+ .and change { container_expiration_policy.reload.older_than }.from(from[:older_than]).to(to[:older_than])
+ end
+ end
+end
+
+RSpec.shared_examples 'not creating the container expiration policy' do
+ it "doesn't create the container expiration policy" do
+ expect { subject }.not_to change { ContainerExpirationPolicy.count }
+ end
+end
+
+RSpec.shared_examples 'creating the container expiration policy' do
+ it_behaves_like 'updating the container expiration policy attributes', mode: :create, to: { cadence: '3month', keep_n: 100, older_than: '14d' }
+
+ it_behaves_like 'returning a success'
+end
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 71bdd46572f..efcb83a34af 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
@@ -45,7 +45,7 @@ RSpec.shared_examples 'WikiPages::CreateService#execute' do |container_type|
expect { service.execute }.to change { Event.count }.by 1
expect(Event.recent.first).to have_attributes(
- action: Event::CREATED,
+ action: 'created',
target: have_attributes(canonical_slug: page_title)
)
end
diff --git a/spec/support/shared_examples/services/wiki_pages/destroy_service_shared_examples.rb b/spec/support/shared_examples/services/wiki_pages/destroy_service_shared_examples.rb
index 62541eb3da9..1231c012c31 100644
--- a/spec/support/shared_examples/services/wiki_pages/destroy_service_shared_examples.rb
+++ b/spec/support/shared_examples/services/wiki_pages/destroy_service_shared_examples.rb
@@ -27,7 +27,7 @@ RSpec.shared_examples 'WikiPages::DestroyService#execute' do |container_type|
expect { service.execute(page) }.to change { Event.count }.by 1
expect(Event.recent.first).to have_attributes(
- action: Event::DESTROYED,
+ action: 'destroyed',
target: have_attributes(canonical_slug: page.slug)
)
end
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 0dfc99d043b..77354fec069 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
@@ -48,7 +48,7 @@ RSpec.shared_examples 'WikiPages::UpdateService#execute' do |container_type|
expect { service.execute(page) }.to change { Event.count }.by 1
expect(Event.recent.first).to have_attributes(
- action: Event::UPDATED,
+ action: 'updated',
wiki_page: page,
target_title: page.title
)