dashboard.rb 2.84 KB
Newer Older
1
class Dashboard < Spinach::FeatureSteps
Nihad Abbasov's avatar
Nihad Abbasov committed
2 3 4
  include SharedAuthentication
  include SharedPaths

5 6 7 8 9 10 11 12 13 14 15 16 17 18
  Then 'I should see "New Project" link' do
    page.should have_link "New Project"
  end

  Then 'I should see "Shop" project link' do
    page.should have_link "Shop"
  end

  Then 'I should see project "Shop" activity feed' do
    project = Project.find_by_name("Shop")
    page.should have_content "#{@user.name} pushed new branch new_design at #{project.name}"
  end

  Then 'I should see last push widget' do
19
    page.should have_content "You pushed to new_design"
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
    page.should have_link "Create Merge Request"
  end

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

  Then 'I see prefilled new Merge Request page' do
    current_path.should == new_project_merge_request_path(@project)
    find("#merge_request_source_branch").value.should == "new_design"
    find("#merge_request_target_branch").value.should == "master"
    find("#merge_request_title").value.should == "New Design"
  end

  Given 'user with name "John Doe" joined project "Shop"' do
35
    user = create :user, {name: "John Doe"}
36 37 38 39 40 41 42 43
    project = Project.find_by_name "Shop"
    Event.create(
      project: project,
      author_id: user.id,
      action: Event::Joined
    )
  end

Nihad Abbasov's avatar
Nihad Abbasov committed
44 45
  Then 'I should see "John Doe joined project at Shop" event' do
    page.should have_content "John Doe joined project at Shop"
46 47 48 49 50 51 52 53 54 55 56 57
  end

  And 'user with name "John Doe" left project "Shop"' do
    user = User.find_by_name "John Doe"
    project = Project.find_by_name "Shop"
    Event.create(
      project: project,
      author_id: user.id,
      action: Event::Left
    )
  end

Nihad Abbasov's avatar
Nihad Abbasov committed
58 59
  Then 'I should see "John Doe left project at Shop" event' do
    page.should have_content "John Doe left project at Shop"
60 61 62
  end

  And 'I own project "Shop"' do
63
    @project = create :project, name: 'Shop'
64 65 66
    @project.add_access(@user, :admin)
  end

randx's avatar
randx committed
67
  And 'I have group with projects' do
68 69 70
    @group   = create :group
    @project = create :project, group: @group
    @event   = create :closed_issue_event, project: @project
randx's avatar
randx committed
71 72 73 74

    @project.add_access current_user, :admin
  end

75 76 77 78
  And 'project "Shop" has push event' do
    @project = Project.find_by_name("Shop")

    data = {
79 80 81 82 83 84 85 86 87 88 89
      before: "0000000000000000000000000000000000000000",
      after: "0220c11b9a3e6c69dc8fd35321254ca9a7b98f7e",
      ref: "refs/heads/new_design",
      user_id: @user.id,
      user_name: @user.name,
      repository: {
        name: @project.name,
        url: "localhost/rubinius",
        description: "",
        homepage: "localhost/rubinius",
        private: true
90 91 92 93
      }
    }

    @event = Event.create(
94 95 96 97
      project: @project,
      action: Event::Pushed,
      data: data,
      author_id: @user.id
98 99
    )
  end
randx's avatar
randx committed
100 101 102 103 104 105

  Then 'I should see groups list' do
    Group.all.each do |group|
      page.should have_link group.name
    end
  end
106
end