group.rb 2.8 KB
Newer Older
1 2 3 4 5
class Groups < Spinach::FeatureSteps
  include SharedAuthentication
  include SharedPaths

  Then 'I should see projects list' do
D
Dmitriy Zaporozhets 已提交
6
    current_user.authorized_projects.each do |project|
7 8 9 10 11
      page.should have_link project.name
    end
  end

  And 'I have group with projects' do
A
Andrey Kumanyaev 已提交
12
    @group   = create(:group, owner: current_user)
13 14
    @project = create(:project, group: @group)
    @event   = create(:closed_issue_event, project: @project)
15

16
    @project.team << [current_user, :master]
17 18 19 20 21 22
  end

  And 'I should see projects activity feed' do
    page.should have_content 'closed issue'
  end

R
randx 已提交
23 24 25 26 27 28 29 30
  Then 'I should see issues from this group assigned to me' do
    assigned_to_me(:issues).each do |issue|
      page.should have_content issue.title
    end
  end

  Then 'I should see merge requests from this group assigned to me' do
    assigned_to_me(:merge_requests).each do |issue|
C
Cyril 已提交
31
      page.should have_content issue.title[0..80]
R
randx 已提交
32 33 34
    end
  end

A
Andrey Kumanyaev 已提交
35 36 37 38
  Given 'I have new user "John"' do
    create(:user, name: "John")
  end

A
Andrey Kumanyaev 已提交
39
  And 'I select user "John" from list with role "Reporter"' do
A
Andrey Kumanyaev 已提交
40 41 42 43 44 45 46 47 48
    user = User.find_by_name("John")
    within "#new_team_member" do
      select user.name, :from => "user_ids"
      select "Reporter", :from => "project_access"
    end
    click_button "Add"
  end

  Then 'I should see user "John" in team list' do
A
Andrey Kumanyaev 已提交
49
    projects_with_access = find(".ui-box .well-list")
A
Andrey Kumanyaev 已提交
50 51 52
    projects_with_access.should have_content("John")
  end

R
randx 已提交
53 54 55 56 57 58 59 60 61 62 63 64 65 66
  Given 'project from group has issues assigned to me' do
    create :issue,
      project: project,
      assignee: current_user,
      author: current_user
  end

  Given 'project from group has merge requests assigned to me' do
    create :merge_request,
      project: project,
      assignee: current_user,
      author: current_user
  end

D
Dmitriy Zaporozhets 已提交
67 68 69 70 71
  When 'I click new group link' do
    click_link "New Group"
  end

  And 'submit form with new group info' do
A
Andrew8xx8 已提交
72 73
    fill_in 'group_name', with: 'Samurai'
    fill_in 'group_description', with: 'Tokugawa Shogunate'
D
Dmitriy Zaporozhets 已提交
74 75 76 77 78
    click_button "Create group"
  end

  Then 'I should see newly created group' do
    page.should have_content "Samurai"
79
    page.should have_content "Tokugawa Shogunate"
D
Dmitriy Zaporozhets 已提交
80 81 82 83 84 85 86
    page.should have_content "You will only see events from projects in this group"
  end

  Then 'I should be redirected to group page' do
    current_path.should == group_path(Group.last)
  end

87 88 89 90 91 92 93 94 95 96 97
  And 'I change group name' do
    fill_in 'group_name', :with => 'new-name'
    click_button "Save group"
  end

  Then 'I should see new group name' do
    within ".navbar-gitlab" do
      page.should have_content "group: new-name"
    end
  end

98 99 100 101 102
  protected

  def current_group
    @group ||= Group.first
  end
R
randx 已提交
103 104

  def project
105
    current_group.projects.first
R
randx 已提交
106 107 108 109 110
  end

  def assigned_to_me key
    project.send(key).where(assignee_id: current_user.id)
  end
111
end