diff options
Diffstat (limited to 'spec/features/dashboard/snippets_spec.rb')
-rw-r--r-- | spec/features/dashboard/snippets_spec.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/features/dashboard/snippets_spec.rb b/spec/features/dashboard/snippets_spec.rb index 4fb01995cb0..ff3eb58931d 100644 --- a/spec/features/dashboard/snippets_spec.rb +++ b/spec/features/dashboard/snippets_spec.rb @@ -6,6 +6,7 @@ describe 'Dashboard snippets' do context 'when the project has snippets' do let(:project) { create(:project, :public) } let!(:snippets) { create_list(:project_snippet, 2, :public, author: project.owner, project: project) } + before do allow(Snippet).to receive(:default_per_page).and_return(1) sign_in(project.owner) @@ -13,10 +14,16 @@ describe 'Dashboard snippets' do end it_behaves_like 'paginated snippets' + + it 'shows new snippet button in header' do + parent_element = page.find('.page-title-controls') + expect(parent_element).to have_link('New snippet') + end end context 'when there are no project snippets', :js do let(:project) { create(:project, :public) } + before do sign_in(project.owner) visit dashboard_snippets_path @@ -28,6 +35,11 @@ describe 'Dashboard snippets' do expect(element).to have_content("Snippets are small pieces of code or notes that you want to keep.") expect(element.find('.svg-content img')['src']).to have_content('illustrations/snippets_empty') end + + it 'shows new snippet button in main content area' do + parent_element = page.find('.row.empty-state') + expect(parent_element).to have_link('New snippet') + end end context 'filtering by visibility' do @@ -76,4 +88,26 @@ describe 'Dashboard snippets' do expect(page).to have_content(snippets[0].title) end end + + context 'as an external user' do + let(:user) { create(:user, :external) } + before do + sign_in(user) + visit dashboard_snippets_path + end + + context 'without snippets' do + it 'hides new snippet button' do + expect(page).not_to have_link('New snippet') + end + end + + context 'with snippets' do + let!(:snippets) { create(:personal_snippet, author: user) } + + it 'hides new snippet button' do + expect(page).not_to have_link('New snippet') + end + end + end end |