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

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

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

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

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

R
randx 已提交
24 25 26 27 28 29 30 31
  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 已提交
32
      page.should have_content issue.title[0..80]
R
randx 已提交
33 34 35
    end
  end

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

A
Andrey Kumanyaev 已提交
40
  And 'I select user "John" from list with role "Reporter"' do
A
Andrey Kumanyaev 已提交
41
    user = User.find_by_name("John")
D
Dmitriy Zaporozhets 已提交
42
    within ".new_users_group" do
43
      select2(user.id, from: "#user_ids", multiple: true)
D
Dmitriy Zaporozhets 已提交
44
      select "Reporter", from: "group_access"
A
Andrey Kumanyaev 已提交
45
    end
D
Dmitriy Zaporozhets 已提交
46
    click_button "Add users into group"
A
Andrey Kumanyaev 已提交
47 48 49
  end

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

R
randx 已提交
54 55 56 57 58 59 60 61 62 63 64 65 66 67
  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 已提交
68 69 70 71 72
  When 'I click new group link' do
    click_link "New Group"
  end

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

  Then 'I should see newly created group' do
    page.should have_content "Samurai"
80
    page.should have_content "Tokugawa Shogunate"
D
Dmitriy Zaporozhets 已提交
81 82 83 84 85 86 87
    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

88
  And 'I change group name' do
89
    fill_in 'group_name', with: 'new-name'
90 91 92 93 94 95 96 97 98
    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

99 100 101 102 103
  protected

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

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

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