diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-04 15:08:09 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-04 15:08:09 +0000 |
commit | d3fc3be040a4fed2328e23ef28696dd8bd8238b4 (patch) | |
tree | f1874ea5e6e3c50c6a3c2ca2900af4ae73a53119 /spec/support/shared_examples/requests | |
parent | c6c7437861bff9572747674095c4dfbdfbea4988 (diff) | |
download | gitlab-ce-d3fc3be040a4fed2328e23ef28696dd8bd8238b4.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/support/shared_examples/requests')
-rw-r--r-- | spec/support/shared_examples/requests/snippet_shared_examples.rb | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/spec/support/shared_examples/requests/snippet_shared_examples.rb b/spec/support/shared_examples/requests/snippet_shared_examples.rb new file mode 100644 index 00000000000..f2df97a35d9 --- /dev/null +++ b/spec/support/shared_examples/requests/snippet_shared_examples.rb @@ -0,0 +1,43 @@ +# frozen_string_literal: true + +RSpec.shared_examples 'update with repository actions' do + context 'when the repository exists' do + it 'commits the changes to the repository' do + existing_blob = snippet.blobs.first + new_file_name = existing_blob.path + '_new' + new_content = 'New content' + + update_snippet(params: { content: new_content, file_name: new_file_name }) + + aggregate_failures do + expect(response).to have_gitlab_http_status(:ok) + expect(snippet.repository.blob_at('master', existing_blob.path)).to be_nil + + blob = snippet.repository.blob_at('master', new_file_name) + expect(blob).not_to be_nil + expect(blob.data).to eq(new_content) + end + end + end + + context 'when the repository does not exist' do + let(:snippet) { snippet_without_repo } + + it 'creates the repository' do + update_snippet(snippet_id: snippet.id, params: { title: 'foo' }) + + expect(snippet.repository).to exist + end + + it 'commits the file to the repository' do + content = 'New Content' + file_name = 'file_name.rb' + + update_snippet(snippet_id: snippet.id, params: { content: content, file_name: file_name }) + + blob = snippet.repository.blob_at('master', file_name) + expect(blob).not_to be_nil + expect(blob.data).to eq content + end + end +end |