dashboard_steps.rb 3.39 KB
Newer Older
randx's avatar
randx committed
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
Then /^I should see "(.*?)" link$/ do |arg1|
  page.should have_link(arg1)
end

Then /^I should see "(.*?)" project link$/ do |arg1|
  page.should have_link(arg1)
end

Then /^I should see project "(.*?)" activity feed$/ do |arg1|
  project = Project.find_by_name(arg1)
  page.should have_content "#{@user.name} pushed new branch new_design at #{project.name}"
end

Given /^project "(.*?)" has push event$/ do |arg1|
  @project = Project.find_by_name(arg1)

  data = {
    :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
    }
  }

  @event = Event.create(
    :project => @project,
    :action => Event::Pushed,
    :data => data,
    :author_id => @user.id
  )
end

Then /^I should see last push widget$/ do
randx's avatar
randx committed
41
  page.should have_content "Your pushed to branch new_design"
randx's avatar
randx committed
42 43 44 45
  page.should have_link "Create Merge Request"
end

Then /^I click "(.*?)" link$/ do |arg1|
randx's avatar
randx committed
46
  click_link arg1 #Create Merge Request"
randx's avatar
randx committed
47 48 49
end

Then /^I see prefilled new Merge Request page$/ do
randx's avatar
randx committed
50 51 52 53
  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"
randx's avatar
randx committed
54 55 56 57 58 59 60 61 62 63
end

Given /^I visit dashboard search page$/ do
  visit search_path
end

Given /^I search for "(.*?)"$/ do |arg1|
  fill_in "dashboard_search", :with => arg1
  click_button "Search"
end
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81

Then /^I should see issues assigned to me$/ do
  issues = @user.issues
  issues.each do |issue|
    page.should have_content(issue.title[0..10])
    page.should have_content(issue.project.name)
  end
end

Then /^I should see my merge requests$/ do
  merge_requests = @user.merge_requests
  merge_requests.each do |mr|
    page.should have_content(mr.title[0..10])
    page.should have_content(mr.project.name)
  end
end

Given /^I have assigned issues$/ do
82 83
  project = Factory :project
  project.add_access(@user, :read, :write)
84 85 86 87

  issue1 = Factory :issue,
   :author => @user,
   :assignee => @user,
88
   :project => project
89 90 91 92

  issue2 = Factory :issue,
   :author => @user,
   :assignee => @user,
93
   :project => project
94 95 96
end

Given /^I have authored merge requests$/ do
97
  project1 = Factory :project
98

99
  project2 = Factory :project
100 101 102 103 104 105 106 107 108 109 110 111

  project1.add_access(@user, :read, :write)
  project2.add_access(@user, :read, :write)

  merge_request1 = Factory :merge_request,
   :author => @user,
   :project => project1

  merge_request2 = Factory :merge_request,
   :author => @user,
   :project => project2
end
112 113 114 115 116 117 118 119 120 121 122

Given /^user with name "(.*?)" joined project "(.*?)"$/ do |user_name, project_name|
  user = Factory.create(:user, {name: user_name})
  project = Project.find_by_name project_name
  Event.create(
    project: project,
    author_id: user.id,
    action: Event::Joined
  )
end

Alex Denisov's avatar
Alex Denisov committed
123 124 125 126 127 128 129 130 131 132
Given /^user with name "(.*?)" left project "(.*?)"$/ do |user_name, project_name|
  user = User.find_by_name user_name
  project = Project.find_by_name project_name
  Event.create(
    project: project,
    author_id: user.id,
    action: Event::Left
  )
end

133 134 135 136
Then /^I should see "(.*?)" event$/ do |event_text|
  page.should have_content(event_text)
end