summaryrefslogtreecommitdiff
path: root/features/steps/project/redirects.rb
blob: 92936f27c2054ec9b56801698494876d6c872530 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
class Spinach::Features::ProjectRedirects < Spinach::FeatureSteps
  include SharedAuthentication
  include SharedPaths
  include SharedProject

  step 'public project "Community"' do
    create(:empty_project, :public, name: 'Community')
  end

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

  step 'I visit project "Community" page' do
    project = Project.find_by(name: 'Community')
    visit namespace_project_path(project.namespace, project)
  end

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

  step 'I visit project "Enterprise" page' do
    project = Project.find_by(name: 'Enterprise')
    visit namespace_project_path(project.namespace, project)
  end

  step 'I visit project "CommunityDoesNotExist" page' do
    project = Project.find_by(name: 'Community')
    visit namespace_project_path(project.namespace, project) + 'DoesNotExist'
  end

  step 'I click on "Sign In"' do
    first(:link, "Sign in").click
  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')
    expect(current_path).to eq "/#{project.path_with_namespace}"
    expect(status_code).to eq 200
  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')
    expect(current_path).to eq "/#{project.path_with_namespace}"
    expect(status_code).to eq 200
  end
end