2019-07-25 01:24:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-08-29 03:56:52 -04:00
|
|
|
require 'spec_helper'
|
2016-11-19 01:12:47 -05:00
|
|
|
|
2020-06-03 14:08:28 -04:00
|
|
|
RSpec.describe 'User Snippets' do
|
2016-11-19 01:12:47 -05:00
|
|
|
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-07-05 02:32:05 -04:00
|
|
|
before do
|
2017-06-21 19:44:10 -04:00
|
|
|
sign_in author
|
2016-11-19 01:12:47 -05:00
|
|
|
visit dashboard_snippets_path
|
|
|
|
end
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'View all of my snippets' do
|
2019-12-10 16:08:01 -05:00
|
|
|
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))
|
2016-11-19 01:12:47 -05:00
|
|
|
end
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'View my public snippets' do
|
2016-11-19 01:12:47 -05:00
|
|
|
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-07-05 02:32:05 -04:00
|
|
|
it 'View my internal snippets' do
|
2016-11-19 01:12:47 -05:00
|
|
|
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-07-05 02:32:05 -04:00
|
|
|
it 'View my private snippets' do
|
2016-11-19 01:12:47 -05:00
|
|
|
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
|