2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
RSpec.describe 'Projects > Snippets > User deletes a snippet', :js do
|
2018-03-17 18:26:18 +05:30
|
|
|
let(:project) { create(:project) }
|
2021-01-03 14:25:43 +05:30
|
|
|
let!(:snippet) { create(:project_snippet, :repository, project: project, author: user) }
|
2018-03-17 18:26:18 +05:30
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
|
|
|
before do
|
2018-11-18 11:00:15 +05:30
|
|
|
project.add_maintainer(user)
|
2018-03-17 18:26:18 +05:30
|
|
|
sign_in(user)
|
|
|
|
|
|
|
|
visit(project_snippet_path(project, snippet))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'deletes a snippet' do
|
2021-01-03 14:25:43 +05:30
|
|
|
expect(page).to have_content(snippet.title)
|
|
|
|
|
|
|
|
click_button('Delete')
|
|
|
|
click_button('Delete snippet')
|
|
|
|
wait_for_requests
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2021-03-08 18:12:59 +05:30
|
|
|
# This assertion also confirms we did not end up on an error page
|
|
|
|
expect(page).to have_selector('#new_snippet_link')
|
|
|
|
expect(project.snippets.length).to eq(0)
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
end
|