2016-11-07 03:01:27 -05:00
|
|
|
require 'rails_helper'
|
|
|
|
|
2017-06-29 00:13:10 -04:00
|
|
|
feature 'Explore Snippets' do
|
2017-04-28 18:06:27 -04:00
|
|
|
let!(:public_snippet) { create(:personal_snippet, :public) }
|
|
|
|
let!(:internal_snippet) { create(:personal_snippet, :internal) }
|
|
|
|
let!(:private_snippet) { create(:personal_snippet, :private) }
|
2016-11-07 03:01:27 -05:00
|
|
|
|
2017-04-28 18:06:27 -04:00
|
|
|
scenario 'User should see snippets that are not private' do
|
2017-06-21 19:44:10 -04:00
|
|
|
sign_in create(:user)
|
2016-11-07 03:01:27 -05:00
|
|
|
visit explore_snippets_path
|
|
|
|
|
|
|
|
expect(page).to have_content(public_snippet.title)
|
|
|
|
expect(page).to have_content(internal_snippet.title)
|
|
|
|
expect(page).not_to have_content(private_snippet.title)
|
|
|
|
end
|
2017-04-28 18:06:27 -04:00
|
|
|
|
|
|
|
scenario 'External user should see only public snippets' do
|
2017-06-21 19:44:10 -04:00
|
|
|
sign_in create(:user, :external)
|
2017-04-28 18:06:27 -04:00
|
|
|
visit explore_snippets_path
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
scenario 'Not authenticated user should see only public snippets' do
|
|
|
|
visit explore_snippets_path
|
|
|
|
|
|
|
|
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
|
2016-11-07 03:01:27 -05:00
|
|
|
end
|