BigW Consortium Gitlab

fork.rb 2.41 KB
Newer Older
1
class Spinach::Features::ProjectFork < Spinach::FeatureSteps
2 3 4 5 6
  include SharedAuthentication
  include SharedPaths
  include SharedProject

  step 'I click link "Fork"' do
7
    expect(page).to have_content "Shop"
Dmitriy Zaporozhets committed
8
    click_link "Fork project"
9 10 11
  end

  step 'I am a member of project "Shop"' do
12
    @project = create(:project, name: "Shop")
13 14 15 16
    @project.team << [@user, :reporter]
  end

  step 'I should see the forked project page' do
17
    expect(page).to have_content "Forked from"
18 19 20
  end

  step 'I already have a project named "Shop" in my namespace' do
21
    @my_project = create(:project, name: "Shop", namespace: current_user.namespace)
22 23 24
  end

  step 'I should see a "Name has already been taken" warning' do
25
    expect(page).to have_content "Name has already been taken"
26
  end
27 28

  step 'I fork to my namespace' do
29
    page.within '.fork-namespaces' do
30 31 32
      click_link current_user.name
    end
  end
33

34 35
  step 'I should see "New merge request"' do
    expect(page).to have_content(/new merge request/i)
36 37 38
  end

  step 'I goto the Merge Requests page' do
39
    page.within '.layout-nav' do
40 41 42
      click_link "Merge Requests"
    end
  end
43 44 45 46 47 48 49 50 51

  step 'I click link "New merge request"' do
    expect(page).to have_content(/new merge request/i)
    click_link "New Merge Request"
  end

  step 'I should see the new merge request page for my namespace' do
    current_path.should have_content(/#{current_user.namespace.name}/i)
  end
52 53 54 55 56 57 58 59 60 61 62 63 64

  step 'I visit the forks page of the "Shop" project' do
    @project = Project.where(name: 'Shop').last
    visit namespace_project_forks_path(@project.namespace, @project)
  end

  step 'I should see my fork on the list' do
    page.within('.projects-list-holder') do
      project = @user.fork_of(@project)
      expect(page).to have_content("#{project.namespace.human_name} / #{project.name}")
    end
  end

65 66 67 68 69 70
  step 'I make forked repo invalid' do
    project = @user.fork_of(@project)
    project.path = 'test-crappy-path'
    project.save!
  end

71 72
  step 'There is an existent fork of the "Shop" project' do
    user = create(:user, name: 'Mike')
73
    @project.team << [user, :reporter]
74 75 76 77 78 79 80 81 82 83
    @forked_project = Projects::ForkService.new(@project, user).execute
  end

  step 'I should not see the other fork listed' do
    expect(page).not_to have_content("#{@forked_project.namespace.human_name} / #{@forked_project.name}")
  end

  step 'I should see a private fork notice' do
    expect(page).to have_content("1 private fork")
  end
84
end