BigW Consortium Gitlab

redirects.rb 2.01 KB
Newer Older
1 2 3 4 5 6
class Spinach::Features::ProjectRedirects < Spinach::FeatureSteps
  include SharedAuthentication
  include SharedPaths
  include SharedProject

  step 'public project "Community"' do
7
    create :project, :public, name: 'Community'
8 9 10 11 12 13 14
  end

  step 'private project "Enterprise"' do
    create :project, name: 'Enterprise'
  end

  step 'I visit project "Community" page' do
skv committed
15
    project = Project.find_by(name: 'Community')
Vinnie Okada committed
16
    visit namespace_project_path(project.namespace, project)
17 18 19
  end

  step 'I should see project "Community" home page' do
20
    Gitlab.config.gitlab.should_receive(:host).and_return("www.example.com")
21
    page.within '.navbar-gitlab .title' do
22
      expect(page).to have_content 'Community'
23 24 25 26
    end
  end

  step 'I visit project "Enterprise" page' do
skv committed
27
    project = Project.find_by(name: 'Enterprise')
Vinnie Okada committed
28
    visit namespace_project_path(project.namespace, project)
29 30 31
  end

  step 'I visit project "CommunityDoesNotExist" page' do
skv committed
32
    project = Project.find_by(name: 'Community')
Vinnie Okada committed
33
    visit namespace_project_path(project.namespace, project) + 'DoesNotExist'
34 35
  end

Marin Jankovski committed
36
  step 'I click on "Sign In"' do
Dmitriy Zaporozhets committed
37
    first(:link, "Sign in").click
Marin Jankovski committed
38 39 40 41 42 43 44 45 46 47 48 49
  end

  step 'Authenticate' do
    admin = create(:admin)
    fill_in "user_login", with: admin.email
    fill_in "user_password", with: admin.password
    click_button "Sign in"
    Thread.current[:current_user] = admin
  end

  step 'I should be redirected to "Community" page' do
    project = Project.find_by(name: 'Community')
50 51
    expect(current_path).to eq "/#{project.path_with_namespace}"
    expect(status_code).to eq 200
Marin Jankovski committed
52 53 54 55 56 57 58 59 60 61 62 63
  end

  step 'I get redirected to signin page where I sign in' do
    admin = create(:admin)
    fill_in "user_login", with: admin.email
    fill_in "user_password", with: admin.password
    click_button "Sign in"
    Thread.current[:current_user] = admin
  end

  step 'I should be redirected to "Enterprise" page' do
    project = Project.find_by(name: 'Enterprise')
64 65
    expect(current_path).to eq "/#{project.path_with_namespace}"
    expect(status_code).to eq 200
Marin Jankovski committed
66 67
  end
end