BigW Consortium Gitlab

pages_spec.rb 1.44 KB
Newer Older
1 2
require 'spec_helper'

3
feature 'Pages' do
4
  given(:project) { create(:project) }
5 6 7 8
  given(:user) { create(:user) }
  given(:role) { :master }

  background do
9 10
    allow(Gitlab.config.pages).to receive(:enabled).and_return(true)

11 12
    project.team << [user, role]

13
    sign_in(user)
14 15 16 17
  end

  shared_examples 'no pages deployed' do
    scenario 'does not see anything to destroy' do
18
      visit project_pages_path(project)
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35

      expect(page).not_to have_link('Remove pages')
      expect(page).not_to have_text('Only the project owner can remove pages')
    end
  end

  context 'when user is the owner' do
    background do
      project.namespace.update(owner: user)
    end

    context 'when pages deployed' do
      background do
        allow_any_instance_of(Project).to receive(:pages_deployed?) { true }
      end

      scenario 'sees "Remove pages" link' do
36
        visit project_pages_path(project)
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51

        expect(page).to have_link('Remove pages')
      end
    end

    it_behaves_like 'no pages deployed'
  end

  context 'when the user is not the owner' do
    context 'when pages deployed' do
      background do
        allow_any_instance_of(Project).to receive(:pages_deployed?) { true }
      end

      scenario 'sees "Only the project owner can remove pages" text' do
52
        visit project_pages_path(project)
53 54 55 56 57 58 59 60

        expect(page).to have_text('Only the project owner can remove pages')
      end
    end

    it_behaves_like 'no pages deployed'
  end
end