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

8 9
  Then 'I should see group "Owned" projects list' do
    Group.find_by(name: "Owned").projects.each do |project|
10 11 12 13 14 15 16 17
      page.should have_link project.name
    end
  end

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

18
  Then 'I should see issues from group "Owned" assigned to me' do
R
randx 已提交
19 20 21 22 23
    assigned_to_me(:issues).each do |issue|
      page.should have_content issue.title
    end
  end

24
  Then 'I should see merge requests from group "Owned" assigned to me' do
R
randx 已提交
25
    assigned_to_me(:merge_requests).each do |issue|
C
Cyril 已提交
26
      page.should have_content issue.title[0..80]
R
randx 已提交
27 28 29
    end
  end

30 31
  And 'I select user "Mary Jane" from list with role "Reporter"' do
    user = User.find_by(name: "Mary Jane") || create(:user, name: "Mary Jane")
32
    click_link 'Add members'
D
Dmitriy Zaporozhets 已提交
33
    within ".users-group-form" do
34
      select2(user.id, from: "#user_ids", multiple: true)
D
Dmitriy Zaporozhets 已提交
35
      select "Reporter", from: "group_access"
A
Andrey Kumanyaev 已提交
36
    end
D
Dmitriy Zaporozhets 已提交
37
    click_button "Add users into group"
A
Andrey Kumanyaev 已提交
38 39
  end

40
  Then 'I should see user "John Doe" in team list' do
A
Andrey Kumanyaev 已提交
41
    projects_with_access = find(".ui-box .well-list")
42
    projects_with_access.should have_content("John Doe")
A
Andrey Kumanyaev 已提交
43 44
  end

45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
  Then 'I should not see user "John Doe" in team list' do
    projects_with_access = find(".ui-box .well-list")
    projects_with_access.should_not have_content("John Doe")
  end

  Then 'I should see user "Mary Jane" in team list' do
    projects_with_access = find(".ui-box .well-list")
    projects_with_access.should have_content("Mary Jane")
  end

  Then 'I should not see user "Mary Jane" in team list' do
    projects_with_access = find(".ui-box .well-list")
    projects_with_access.should_not have_content("Mary Jane")
  end

  Given 'project from group "Owned" has issues assigned to me' do
R
randx 已提交
61 62 63 64 65 66
    create :issue,
      project: project,
      assignee: current_user,
      author: current_user
  end

67
  Given 'project from group "Owned" has merge requests assigned to me' do
R
randx 已提交
68
    create :merge_request,
I
Izaak Alpert 已提交
69 70
      source_project: project,
      target_project: project,
R
randx 已提交
71 72 73 74
      assignee: current_user,
      author: current_user
  end

D
Dmitriy Zaporozhets 已提交
75
  When 'I click new group link' do
D
Dmitriy Zaporozhets 已提交
76
    click_link "New group"
D
Dmitriy Zaporozhets 已提交
77 78
  end

79
  And 'submit form with new group "Samurai" info' do
A
Andrew8xx8 已提交
80 81
    fill_in 'group_name', with: 'Samurai'
    fill_in 'group_description', with: 'Tokugawa Shogunate'
D
Dmitriy Zaporozhets 已提交
82 83 84
    click_button "Create group"
  end

85 86 87 88 89
  Then 'I should be redirected to group "Samurai" page' do
    current_path.should == group_path(Group.last)
  end

  Then 'I should see newly created group "Samurai"' do
D
Dmitriy Zaporozhets 已提交
90
    page.should have_content "Samurai"
91
    page.should have_content "Tokugawa Shogunate"
D
Dmitriy Zaporozhets 已提交
92 93 94
    page.should have_content "You will only see events from projects in this group"
  end

95
  And 'I change group "Owned" name to "new-name"' do
96
    fill_in 'group_name', with: 'new-name'
97 98 99
    click_button "Save group"
  end

100
  Then 'I should see new group "Owned" name' do
101 102 103 104 105
    within ".navbar-gitlab" do
      page.should have_content "group: new-name"
    end
  end

106
  step 'I change group "Owned" avatar' do
S
Steven Thonus 已提交
107 108
    attach_file(:group_avatar, File.join(Rails.root, 'public', 'gitlab_logo.png'))
    click_button "Save group"
109
    Group.find_by(name: "Owned").reload
S
Steven Thonus 已提交
110 111
  end

112 113 114
  step 'I should see new group "Owned" avatar' do
    Group.find_by(name: "Owned").avatar.should be_instance_of AttachmentUploader
    Group.find_by(name: "Owned").avatar.url.should == "/uploads/group/avatar/#{ Group.find_by(name:"Owned").id }/gitlab_logo.png"
S
Steven Thonus 已提交
115 116 117 118 119 120
  end

  step 'I should see the "Remove avatar" button' do
    page.should have_link("Remove avatar")
  end

121
  step 'I have group "Owned" avatar' do
S
Steven Thonus 已提交
122 123
    attach_file(:group_avatar, File.join(Rails.root, 'public', 'gitlab_logo.png'))
    click_button "Save group"
124
    Group.find_by(name: "Owned").reload
S
Steven Thonus 已提交
125 126
  end

127
  step 'I remove group "Owned" avatar' do
S
Steven Thonus 已提交
128
    click_link "Remove avatar"
129
    Group.find_by(name: "Owned").reload
S
Steven Thonus 已提交
130 131
  end

132 133
  step 'I should not see group "Owned" avatar' do
    Group.find_by(name: "Owned").avatar?.should be_false
S
Steven Thonus 已提交
134 135 136 137 138 139
  end

  step 'I should not see the "Remove avatar" button' do
    page.should_not have_link("Remove avatar")
  end

140 141 142 143
  step 'I click on the "Remove User From Group" button for "John Doe"' do
    find(:css, 'li', text: "John Doe").find(:css, 'a.btn-remove').click
    # poltergeist always confirms popups.
  end
144

145 146 147
  step 'I click on the "Remove User From Group" button for "Mary Jane"' do
    find(:css, 'li', text: "Mary Jane").find(:css, 'a.btn-remove').click
    # poltergeist always confirms popups.
148
  end
R
randx 已提交
149

150 151 152
  step 'I should not see the "Remove User From Group" button for "John Doe"' do
    find(:css, 'li', text: "John Doe").should_not have_selector(:css, 'a.btn-remove')
    # poltergeist always confirms popups.
R
randx 已提交
153 154
  end

155 156 157 158 159
  step 'I should not see the "Remove User From Group" button for "Mary Jane"' do
    find(:css, 'li', text: "Mary Jane").should_not have_selector(:css, 'a.btn-remove')
    # poltergeist always confirms popups.
  end

160 161 162 163 164 165 166
  step 'I search for \'Mary\' member' do
    within '.member-search-form' do
      fill_in 'search', with: 'Mary'
      click_button 'Search'
    end
  end

167 168
  protected

R
randx 已提交
169 170 171
  def assigned_to_me key
    project.send(key).where(assignee_id: current_user.id)
  end
172 173 174 175

  def project
    Group.find_by(name: "Owned").projects.first
  end
176
end