summaryrefslogtreecommitdiff
path: root/features/steps/dashboard/dashboard.rb
blob: 5062e3488441ee55a4b452d20252b8f336c81a5e (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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
class Spinach::Features::Dashboard < Spinach::FeatureSteps
  include SharedAuthentication
  include SharedPaths
  include SharedProject
  include SharedIssuable

  step 'I should see "New Project" link' do
    expect(page).to have_link "New project"
  end

  step 'I should see "Shop" project link' do
    expect(page).to have_link "Shop"
  end

  step 'I should see "Shop" project CI status' do
    expect(page).to have_link "Build skipped"
  end

  step 'I should see last push widget' do
    expect(page).to have_content "You pushed to fix"
    expect(page).to have_link "Create Merge Request"
  end

  step 'I click "Create Merge Request" link' do
    click_link "Create Merge Request"
  end

  step 'I see prefilled new Merge Request page' do
    expect(current_path).to eq new_namespace_project_merge_request_path(@project.namespace, @project)
    expect(find("#merge_request_target_project_id").value).to eq @project.id.to_s
    expect(find("input#merge_request_source_branch").value).to eq "fix"
    expect(find("input#merge_request_target_branch").value).to eq "master"
  end

  step 'user with name "John Doe" joined project "Shop"' do
    user = create(:user, { name: "John Doe" })
    project.team << [user, :master]
    Event.create(
      project: project,
      author_id: user.id,
      action: Event::JOINED
    )
  end

  step 'I should see "John Doe joined project Shop" event' do
    expect(page).to have_content "John Doe joined project #{project.name_with_namespace}"
  end

  step 'user with name "John Doe" left project "Shop"' do
    user = User.find_by(name: "John Doe")
    Event.create(
      project: project,
      author_id: user.id,
      action: Event::LEFT
    )
  end

  step 'I should see "John Doe left project Shop" event' do
    expect(page).to have_content "John Doe left project #{project.name_with_namespace}"
  end

  step 'I have group with projects' do
    @group   = create(:group)
    @project = create(:project, namespace: @group)
    @event   = create(:closed_issue_event, project: @project)

    @project.team << [current_user, :master]
  end

  step 'I should see projects list' do
    @user.authorized_projects.all.each do |project|
      expect(page).to have_link project.name_with_namespace
    end
  end

  step 'I should see groups list' do
    Group.all.each do |group|
      expect(page).to have_link group.name
    end
  end

  step 'group has a projects that does not belongs to me' do
    @forbidden_project1 = create(:project, group: @group)
    @forbidden_project2 = create(:project, group: @group)
  end

  step 'I should see 1 project at group list' do
    expect(find('span.last_activity/span')).to have_content('1')
  end
end