BigW Consortium Gitlab

groups.rb 3.95 KB
Newer Older
1
class Spinach::Features::Groups < Spinach::FeatureSteps
2 3
  include SharedAuthentication
  include SharedPaths
4
  include SharedGroup
5
  include SharedUser
6

Valery Sizov committed
7 8 9 10 11 12 13 14 15
  step 'I should see group "Owned"' do
    expect(page).to have_content '@owned'
  end

  step 'I am a signed out user' do
    logout
  end

  step 'Group "Owned" has a public project "Public-project"' do
16
    group = owned_group
Valery Sizov committed
17 18 19 20 21 22 23 24 25 26

    @project = create :empty_project, :public,
                 group: group,
                 name: "Public-project"
  end

  step 'I should see project "Public-project"' do
    expect(page).to have_content 'Public-project'
  end

27
  step 'I should see group "Owned" projects list' do
28
    owned_group.projects.each do |project|
29
      expect(page).to have_link project.name
30 31 32
    end
  end

33
  step 'I should see projects activity feed' do
34
    expect(page).to have_content 'joined project'
35 36
  end

37
  step 'I should see issues from group "Owned" assigned to me' do
randx committed
38
    assigned_to_me(:issues).each do |issue|
39
      expect(page).to have_content issue.title
randx committed
40 41 42
    end
  end

43 44 45 46 47 48
  step 'I should not see issues from the archived project' do
    @archived_project.issues.each do |issue|
      expect(page).not_to have_content issue.title
    end
  end

49 50 51 52 53 54
  step 'I should not see merge requests from the archived project' do
    @archived_project.merge_requests.each do |mr|
      expect(page).not_to have_content mr.title
    end
  end

55
  step 'I should see merge requests from group "Owned" assigned to me' do
randx committed
56
    assigned_to_me(:merge_requests).each do |issue|
57
      expect(page).to have_content issue.title[0..80]
randx committed
58 59 60
    end
  end

61
  step 'project from group "Owned" has issues assigned to me' do
randx committed
62 63
    create :issue,
      project: project,
64
      assignees: [current_user],
randx committed
65 66 67
      author: current_user
  end

68
  step 'project from group "Owned" has merge requests assigned to me' do
randx committed
69
    create :merge_request,
70 71
      source_project: project,
      target_project: project,
randx committed
72 73 74 75
      assignee: current_user,
      author: current_user
  end

76
  step 'I change group "Owned" avatar' do
77
    attach_file(:group_avatar, File.join(Rails.root, 'spec', 'fixtures', 'banana_sample.gif'))
Steven Thonus committed
78
    click_button "Save group"
79
    owned_group.reload
Steven Thonus committed
80 81
  end

82
  step 'I should see new group "Owned" avatar' do
83
    expect(owned_group.avatar).to be_instance_of AvatarUploader
84
    expect(owned_group.avatar.url).to eq "/uploads/group/avatar/#{Group.find_by(name: "Owned").id}/banana_sample.gif"
Steven Thonus committed
85 86 87
  end

  step 'I should see the "Remove avatar" button' do
88
    expect(page).to have_link("Remove avatar")
Steven Thonus committed
89 90
  end

91
  step 'I have group "Owned" avatar' do
92
    attach_file(:group_avatar, File.join(Rails.root, 'spec', 'fixtures', 'banana_sample.gif'))
Steven Thonus committed
93
    click_button "Save group"
94
    owned_group.reload
Steven Thonus committed
95 96
  end

97
  step 'I remove group "Owned" avatar' do
Steven Thonus committed
98
    click_link "Remove avatar"
99
    owned_group.reload
Steven Thonus committed
100 101
  end

102
  step 'I should not see group "Owned" avatar' do
103
    expect(owned_group.avatar?).to eq false
Steven Thonus committed
104 105 106
  end

  step 'I should not see the "Remove avatar" button' do
107
    expect(page).not_to have_link("Remove avatar")
Steven Thonus committed
108 109
  end

Artem Sidorenko committed
110 111
  step 'Group "Owned" has archived project' do
    group = Group.find_by(name: 'Owned')
112
    @archived_project = create(:empty_project, :archived, namespace: group, path: "archived-project")
Artem Sidorenko committed
113 114 115 116 117 118
  end

  step 'I should see "archived" label' do
    expect(page).to have_xpath("//span[@class='label label-warning']", text: 'archived')
  end

119
  step 'I visit group "NonExistentGroup" page' do
120
    visit group_path("NonExistentGroup")
121 122
  end

123 124 125
  step 'the archived project have some issues' do
    create :issue,
      project: @archived_project,
126
      assignees: [current_user],
127 128 129
      author: current_user
  end

130 131 132 133 134 135 136 137
  step 'the archived project have some merge requests' do
    create :merge_request,
      source_project: @archived_project,
      target_project: @archived_project,
      assignee: current_user,
      author: current_user
  end

138
  private
139

140
  def assigned_to_me(key)
randx committed
141 142
    project.send(key).where(assignee_id: current_user.id)
  end
143 144

  def project
145
    owned_group.projects.first
146
  end
147
end