BigW Consortium Gitlab

group.rb 5.29 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
randx committed
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
randx committed
25
    assigned_to_me(:merge_requests).each do |issue|
Cyril committed
26
      page.should have_content issue.title[0..80]
randx committed
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'
Dmitriy Zaporozhets committed
33
    within ".users-group-form" do
34
      select2(user.id, from: "#user_ids", multiple: true)
Dmitriy Zaporozhets committed
35
      select "Reporter", from: "group_access"
36
    end
Dmitriy Zaporozhets committed
37
    click_button "Add users into group"
38 39
  end

40
  Then 'I should see user "John Doe" in team list' do
Dmitriy Zaporozhets committed
41
    projects_with_access = find(".panel .well-list")
42
    projects_with_access.should have_content("John Doe")
43 44
  end

45
  Then 'I should not see user "John Doe" in team list' do
Dmitriy Zaporozhets committed
46
    projects_with_access = find(".panel .well-list")
47 48 49 50
    projects_with_access.should_not have_content("John Doe")
  end

  Then 'I should see user "Mary Jane" in team list' do
Dmitriy Zaporozhets committed
51
    projects_with_access = find(".panel .well-list")
52 53 54 55
    projects_with_access.should have_content("Mary Jane")
  end

  Then 'I should not see user "Mary Jane" in team list' do
Dmitriy Zaporozhets committed
56
    projects_with_access = find(".panel .well-list")
57 58 59 60
    projects_with_access.should_not have_content("Mary Jane")
  end

  Given 'project from group "Owned" has issues assigned to me' do
randx committed
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
randx committed
68
    create :merge_request,
69 70
      source_project: project,
      target_project: project,
randx committed
71 72 73 74
      assignee: current_user,
      author: current_user
  end

75
  When 'I click new group link' do
76
    click_link "New group"
77 78
  end

79
  And 'submit form with new group "Samurai" info' do
Andrew8xx8 committed
80 81
    fill_in 'group_name', with: 'Samurai'
    fill_in 'group_description', with: 'Tokugawa Shogunate'
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
90
    page.should have_content "Samurai"
91
    page.should have_content "Tokugawa Shogunate"
Dmitriy Zaporozhets committed
92
    page.should have_content "Currently you are only seeing events from the"
93 94
  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
Steven Thonus committed
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
Steven Thonus committed
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"
Steven Thonus committed
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
Steven Thonus committed
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
Steven Thonus committed
125 126
  end

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

132 133
  step 'I should not see group "Owned" avatar' do
    Group.find_by(name: "Owned").avatar?.should be_false
Steven Thonus committed
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
randx committed
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.
randx committed
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

randx committed
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