2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
require 'rails_helper'
|
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
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
|
2017-08-17 22:00:37 +05:30
|
|
|
expect(page).to have_content(public_snippet.title)
|
|
|
|
expect(page).to have_content(internal_snippet.title)
|
|
|
|
expect(page).to have_content(private_snippet.title)
|
|
|
|
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
|