BigW Consortium Gitlab

explore_spec.rb 1.14 KB
Newer Older
1 2 3
require 'rails_helper'

feature 'Explore Snippets', feature: true do
4 5 6
  let!(:public_snippet) { create(:personal_snippet, :public) }
  let!(:internal_snippet) { create(:personal_snippet, :internal) }
  let!(:private_snippet) { create(:personal_snippet, :private) }
7

8
  scenario 'User should see snippets that are not private' do
9 10 11 12 13 14 15
    login_as create(:user)
    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
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32

  scenario 'External user should see only public snippets' do
    login_as create(:user, :external)
    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
33
end