Skip to content
Snippets Groups Projects
Commit 4f0e1a03 authored by Anastasia McDonald's avatar Anastasia McDonald Committed by Daniel Davison
Browse files

Introduce deleting of snippets via API

And update the tests to clean up resources

See https://gitlab.com/gitlab-org/quality/team-tasks/-/issues/763
parent 9c8f090c
No related branches found
No related tags found
No related merge requests found
Showing with 41 additions and 3 deletions
Loading
Loading
@@ -33,12 +33,16 @@ def fabricate!
end
 
def api_get_path
"/projects/#{project.id}/snippets/#{snippet_id}"
"/projects/#{project.id}/snippets/#{id}"
end
 
def api_post_path
"/projects/#{project.id}/snippets"
end
def api_delete_path
"/projects/#{project.id}/snippets/#{id}"
end
end
end
end
Loading
Loading
@@ -3,7 +3,9 @@
module QA
module Resource
class Snippet < Base
attr_accessor :title, :description, :file_content, :visibility, :file_name, :snippet_id
attr_accessor :title, :description, :file_content, :visibility, :file_name
attribute :id
 
def initialize
@title = 'New snippet title'
Loading
Loading
@@ -44,7 +46,7 @@ def fabricate_via_api!
end
 
def api_get_path
"/snippets/#{snippet_id}"
"/snippets/#{id}"
end
 
def api_post_path
Loading
Loading
@@ -60,6 +62,10 @@ def api_post_body
}
end
 
def api_delete_path
"/snippets/#{id}"
end
def all_file_contents
@files.insert(0, { name: @file_name, content: @file_content })
@files.each do |file|
Loading
Loading
Loading
Loading
@@ -23,6 +23,11 @@ module QA
Flow::Login.sign_in
end
 
after do
personal_snippet&.remove_via_api!
project_snippet&.remove_via_api!
end
shared_examples 'comments on snippets' do |snippet_type|
it "adds, edits, and deletes a comment on a #{snippet_type}" do
send(snippet_type)
Loading
Loading
Loading
Loading
@@ -23,6 +23,11 @@ module QA
Flow::Login.sign_in
end
 
after do
personal_snippet&.remove_via_api!
project_snippet&.remove_via_api!
end
shared_examples 'adding file to snippet' do |snippet_type|
it "adds second file to an existing #{snippet_type} to make it multi-file" do
send(snippet_type).visit!
Loading
Loading
Loading
Loading
@@ -66,6 +66,8 @@ module QA
expect(repository.commits.first).to include('Update snippet')
expect(repository.file_content(new_file)).to include("#{added_content}#{changed_content}")
end
snippet.remove_via_api!
end
 
it 'clones, pushes, and pulls a snippet over SSH, deletes via UI', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/825' do
Loading
Loading
Loading
Loading
@@ -67,6 +67,8 @@ module QA
expect(repository.commits.first).to include 'Update snippet'
expect(repository.file_content(new_file)).to include "#{added_content}#{changed_content}"
end
snippet.remove_via_api!
end
 
it 'clones, pushes, and pulls a project snippet over SSH, deletes via UI', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/832' do
Loading
Loading
Loading
Loading
@@ -54,6 +54,11 @@ module QA
Flow::Login.sign_in
end
 
after do
personal_snippet&.remove_via_api!
project_snippet&.remove_via_api!
end
shared_examples 'copying snippet file contents' do |snippet_type|
it "copies file contents of a multi-file #{snippet_type} to a comment and verifies them" do
send(snippet_type).visit!
Loading
Loading
Loading
Loading
@@ -31,6 +31,11 @@ module QA
Flow::Login.sign_in
end
 
after do
personal_snippet&.remove_via_api!
project_snippet&.remove_via_api!
end
shared_examples 'deleting file from snippet' do |snippet_type|
it "deletes second file from an existing #{snippet_type} to make it single-file" do
send(snippet_type).visit!
Loading
Loading
Loading
Loading
@@ -16,6 +16,10 @@ module QA
Flow::Login.sign_in
end
 
after do
snippet&.remove_via_api!
end
context 'when the snippet is public' do
it 'can be shared with not signed-in users', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1016' do
snippet.visit!
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment