BigW Consortium Gitlab

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

7
  step 'I should see back to dashboard button' do
8
    expect(page).to have_content 'Go to dashboard'
9 10
  end

Valery Sizov committed
11 12 13 14 15 16 17 18 19
  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
20
    group = owned_group
Valery Sizov committed
21 22 23 24 25 26 27 28 29 30

    @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

31
  step 'I should see group "Owned" projects list' do
32
    owned_group.projects.each do |project|
33
      expect(page).to have_link project.name
34 35 36
    end
  end

37
  step 'I should see projects activity feed' do
38
    expect(page).to have_content 'closed issue'
39 40
  end

41
  step 'I should see issues from group "Owned" assigned to me' do
randx committed
42
    assigned_to_me(:issues).each do |issue|
43
      expect(page).to have_content issue.title
randx committed
44 45 46
    end
  end

47
  step 'I should see merge requests from group "Owned" assigned to me' do
randx committed
48
    assigned_to_me(:merge_requests).each do |issue|
49
      expect(page).to have_content issue.title[0..80]
randx committed
50 51 52
    end
  end

53
  step 'project from group "Owned" has issues assigned to me' do
randx committed
54 55 56 57 58 59
    create :issue,
      project: project,
      assignee: current_user,
      author: current_user
  end

60
  step 'project from group "Owned" has merge requests assigned to me' do
randx committed
61
    create :merge_request,
62 63
      source_project: project,
      target_project: project,
randx committed
64 65 66 67
      assignee: current_user,
      author: current_user
  end

68
  step 'I change group "Owned" name to "new-name"' do
69
    fill_in 'group_name', with: 'new-name'
70
    fill_in 'group_path', with: 'new-name'
71 72 73
    click_button "Save group"
  end

74
  step 'I should see new group "Owned" name' do
75
    page.within ".navbar-gitlab" do
76
      expect(page).to have_content "new-name"
77 78 79
    end
  end

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

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

  step 'I should see the "Remove avatar" button' do
92
    expect(page).to have_link("Remove avatar")
Steven Thonus committed
93 94
  end

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

101
  step 'I remove group "Owned" avatar' do
Steven Thonus committed
102
    click_link "Remove avatar"
103
    owned_group.reload
Steven Thonus committed
104 105
  end

106
  step 'I should not see group "Owned" avatar' do
107
    expect(owned_group.avatar?).to eq false
Steven Thonus committed
108 109 110
  end

  step 'I should not see the "Remove avatar" button' do
111
    expect(page).not_to have_link("Remove avatar")
Steven Thonus committed
112 113
  end

Artem Sidorenko committed
114 115 116 117 118 119 120 121 122
  step 'Group "Owned" has archived project' do
    group = Group.find_by(name: 'Owned')
    create(:project, namespace: group, archived: true, path: "archived-project")
  end

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

123 124 125 126
  step 'I visit group "NonExistentGroup" page' do
    visit group_path(-1)
  end

127
  private
128

129
  def assigned_to_me(key)
randx committed
130 131
    project.send(key).where(assignee_id: current_user.id)
  end
132 133

  def project
134
    owned_group.projects.first
135
  end
136
end