diff options
Diffstat (limited to 'spec/features/snippets/user_edits_snippet_spec.rb')
-rw-r--r-- | spec/features/snippets/user_edits_snippet_spec.rb | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/spec/features/snippets/user_edits_snippet_spec.rb b/spec/features/snippets/user_edits_snippet_spec.rb index 1d26660a4f6..706758164b2 100644 --- a/spec/features/snippets/user_edits_snippet_spec.rb +++ b/spec/features/snippets/user_edits_snippet_spec.rb @@ -8,7 +8,7 @@ describe 'User edits snippet', :js do let(:file_name) { 'test.rb' } let(:content) { 'puts "test"' } - let(:user) { create(:user) } + let_it_be(:user) { create(:user) } let(:snippet) { create(:personal_snippet, :public, file_name: file_name, content: content, author: user) } before do @@ -58,4 +58,21 @@ describe 'User edits snippet', :js do expect(page).to have_no_xpath("//i[@class='fa fa-lock']") expect(page).to have_xpath("//i[@class='fa fa-globe']") end + + context 'when the git operation fails' do + before do + allow_next_instance_of(Snippets::UpdateService) do |instance| + allow(instance).to receive(:create_commit).and_raise(StandardError) + end + + fill_in 'personal_snippet_title', with: 'New Snippet Title' + + click_button('Save changes') + end + + it 'renders edit page and displays the error' do + expect(page).to have_content('Error updating the snippet') + expect(page).to have_content('Edit Snippet') + end + end end |