debian-mirror-gitlab/spec/features/snippets/user_snippets_spec.rb

52 lines
1.7 KiB
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2019-12-04 20:38:33 +05:30
require 'spec_helper'
2017-08-17 22:00:37 +05:30
2020-06-23 00:09:42 +05:30
RSpec.describe 'User Snippets' do
2017-08-17 22:00:37 +05:30
let(:author) { create(:user) }
let!(:public_snippet) { create(:personal_snippet, :public, author: author, title: "This is a public snippet") }
let!(:internal_snippet) { create(:personal_snippet, :internal, author: author, title: "This is an internal snippet") }
let!(:private_snippet) { create(:personal_snippet, :private, author: author, title: "This is a private snippet") }
2018-11-08 19:23:39 +05:30
before do
2017-09-10 17:25:29 +05:30
sign_in author
2017-08-17 22:00:37 +05:30
visit dashboard_snippets_path
end
2018-11-08 19:23:39 +05:30
it 'View all of my snippets' do
2020-01-01 13:55:28 +05:30
expect(page).to have_link(public_snippet.title, href: snippet_path(public_snippet))
expect(page).to have_link(internal_snippet.title, href: snippet_path(internal_snippet))
expect(page).to have_link(private_snippet.title, href: snippet_path(private_snippet))
2017-08-17 22:00:37 +05:30
end
2018-11-08 19:23:39 +05:30
it 'View my public snippets' do
2017-08-17 22:00:37 +05:30
page.within('.snippet-scope-menu') do
click_link "Public"
end
expect(page).to have_content(public_snippet.title)
expect(page).not_to have_content(internal_snippet.title)
expect(page).not_to have_content(private_snippet.title)
end
2018-11-08 19:23:39 +05:30
it 'View my internal snippets' do
2017-08-17 22:00:37 +05:30
page.within('.snippet-scope-menu') do
click_link "Internal"
end
expect(page).not_to have_content(public_snippet.title)
expect(page).to have_content(internal_snippet.title)
expect(page).not_to have_content(private_snippet.title)
end
2018-11-08 19:23:39 +05:30
it 'View my private snippets' do
2017-08-17 22:00:37 +05:30
page.within('.snippet-scope-menu') do
click_link "Private"
end
expect(page).not_to have_content(public_snippet.title)
expect(page).not_to have_content(internal_snippet.title)
expect(page).to have_content(private_snippet.title)
end
end