Commit f4ca6e9a authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'group-rspec' into 'master'

Replace group spinach tests with RSpec analog

See merge request gitlab-org/gitlab-ce!17818
parents a405f59c d6af33b4
Feature: Groups
Background:
Given I sign in as "John Doe"
And "John Doe" is owner of group "Owned"
Scenario: I should not see a group if it does not exist
When I visit group "NonExistentGroup" page
Then page status code should be 404
@javascript
Scenario: I should see group "Owned" dashboard list
When I visit group "Owned" page
Then I should see group "Owned" projects list
@javascript
Scenario: I should see group "Owned" activity feed
When I visit group "Owned" activity page
And I should see projects activity feed
Scenario: I should see group "Owned" issues list
Given project from group "Owned" has issues assigned to me
When I visit group "Owned" issues page
Then I should see issues from group "Owned" assigned to me
Scenario: I should not see issues from archived project in "Owned" group issues list
Given Group "Owned" has archived project
And the archived project have some issues
When I visit group "Owned" issues page
Then I should not see issues from the archived project
Scenario: I should see group "Owned" merge requests list
Given project from group "Owned" has merge requests assigned to me
When I visit group "Owned" merge requests page
Then I should see merge requests from group "Owned" assigned to me
Scenario: I should not see merge requests from archived project in "Owned" group merge requests list
Given Group "Owned" has archived project
And the archived project have some merge_requests
When I visit group "Owned" merge requests page
Then I should not see merge requests from the archived project
Scenario: I edit group "Owned" avatar
When I visit group "Owned" settings page
And I change group "Owned" avatar
And I visit group "Owned" settings page
Then I should see new group "Owned" avatar
And I should see the "Remove avatar" button
Scenario: I remove group "Owned" avatar
When I visit group "Owned" settings page
And I have group "Owned" avatar
And I visit group "Owned" settings page
And I remove group "Owned" avatar
Then I should not see group "Owned" avatar
And I should not see the "Remove avatar" button
# Group projects in settings
Scenario: I should see all projects in the project list in settings
Given Group "Owned" has archived project
When I visit group "Owned" projects page
Then I should see group "Owned" projects list
And I should see "archived" label
# Public group
@javascript
Scenario: Signed out user should see group
Given "Mary Jane" is owner of group "Owned"
And I am a signed out user
And Group "Owned" has a public project "Public-project"
When I visit group "Owned" page
Then I should see group "Owned"
Then I should see project "Public-project"
class Spinach::Features::Groups < Spinach::FeatureSteps
include SharedAuthentication
include SharedPaths
include SharedGroup
include SharedUser
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
group = owned_group
@project = create :project, :public,
group: group,
name: "Public-project"
end
step 'I should see project "Public-project"' do
expect(page).to have_content 'Public-project'
end
step 'I should see group "Owned" projects list' do
owned_group.projects.each do |project|
expect(page).to have_link project.name
end
end
step 'I should see projects activity feed' do
expect(page).to have_content 'joined project'
end
step 'I should see issues from group "Owned" assigned to me' do
assigned_to_me(:issues).each do |issue|
expect(page).to have_content issue.title
end
end
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
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
step 'I should see merge requests from group "Owned" assigned to me' do
assigned_to_me(:merge_requests).each do |issue|
expect(page).to have_content issue.title[0..80]
end
end
step 'project from group "Owned" has issues assigned to me' do
create :issue,
project: project,
assignees: [current_user],
author: current_user
end
step 'project from group "Owned" has merge requests assigned to me' do
create :merge_request,
source_project: project,
target_project: project,
assignee: current_user,
author: current_user
end
step 'I change group "Owned" avatar' do
attach_file(:group_avatar, File.join(Rails.root, 'spec', 'fixtures', 'banana_sample.gif'))
click_button "Save group"
owned_group.reload
end
step 'I should see new group "Owned" avatar' do
expect(owned_group.avatar).to be_instance_of AvatarUploader
expect(owned_group.avatar.url).to eq "/uploads/-/system/group/avatar/#{Group.find_by(name: "Owned").id}/banana_sample.gif"
end
step 'I should see the "Remove avatar" button' do
expect(page).to have_link("Remove avatar")
end
step 'I have group "Owned" avatar' do
attach_file(:group_avatar, File.join(Rails.root, 'spec', 'fixtures', 'banana_sample.gif'))
click_button "Save group"
owned_group.reload
end
step 'I remove group "Owned" avatar' do
click_link "Remove avatar"
owned_group.reload
end
step 'I should not see group "Owned" avatar' do
expect(owned_group.avatar?).to eq false
end
step 'I should not see the "Remove avatar" button' do
expect(page).not_to have_link("Remove avatar")
end
step 'Group "Owned" has archived project' do
group = Group.find_by(name: 'Owned')
@archived_project = create(:project, :archived, namespace: group, path: "archived-project")
end
step 'I should see "archived" label' do
expect(page).to have_xpath("//span[@class='label label-warning']", text: 'archived')
end
step 'I visit group "NonExistentGroup" page' do
visit group_path("NonExistentGroup")
end
step 'the archived project have some issues' do
create :issue,
project: @archived_project,
assignees: [current_user],
author: current_user
end
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
private
def assigned_to_me(key)
project.send(key).assigned_to(current_user)
end
def project
owned_group.projects.first
end
end
......@@ -8,11 +8,30 @@ feature 'Group activity page' do
context 'when signed in' do
before do
sign_in(user)
visit path
end
it_behaves_like "it has an RSS button with current_user's RSS token"
it_behaves_like "an autodiscoverable RSS feed with current_user's RSS token"
describe 'RSS' do
before do
visit path
end
it_behaves_like "it has an RSS button with current_user's RSS token"
it_behaves_like "an autodiscoverable RSS feed with current_user's RSS token"
end
context 'when project is in the group', :js do
let(:project) { create(:project, :public, namespace: group) }
before do
project.add_master(user)
visit path
end
it 'renders user joined to project event' do
expect(page).to have_content 'joined project'
end
end
end
context 'when signed out' do
......
......@@ -76,6 +76,27 @@ feature 'Edit group settings' do
end
end
end
describe 'edit group avatar' do
before do
visit edit_group_path(group)
attach_file(:group_avatar, Rails.root.join('spec', 'fixtures', 'banana_sample.gif'))
expect { click_button 'Save group' }.to change { group.reload.avatar? }.to(true)
end
it 'uploads new group avatar' do
expect(group.avatar).to be_instance_of AvatarUploader
expect(group.avatar.url).to eq "/uploads/-/system/group/avatar/#{group.id}/banana_sample.gif"
expect(page).to have_link('Remove avatar')
end
it 'removes group avatar' do
expect { click_link 'Remove avatar' }.to change { group.reload.avatar? }.to(false)
expect(page).not_to have_link('Remove avatar')
end
end
end
def update_path(new_group_path)
......
......@@ -3,8 +3,11 @@ require 'spec_helper'
feature 'Group issues page' do
include FilteredSearchHelpers
let(:group) { create(:group) }
let(:project) { create(:project, :public, group: group)}
let(:path) { issues_group_path(group) }
context 'with shared examples' do
let(:path) { issues_group_path(group) }
let(:issuable) { create(:issue, project: project, title: "this is my created issuable")}
include_examples 'project features apply to issuables', Issue
......@@ -31,7 +34,6 @@ feature 'Group issues page' do
let(:access_level) { ProjectFeature::ENABLED }
let(:user) { user_in_group }
let(:user2) { user_outside_group }
let(:path) { issues_group_path(group) }
it 'filters by only group users' do
filtered_search.set('assignee:')
......@@ -43,9 +45,7 @@ feature 'Group issues page' do
end
context 'issues list', :nested_groups do
let(:group) { create(:group)}
let(:subgroup) { create(:group, parent: group) }
let(:project) { create(:project, :public, group: group)}
let(:subgroup_project) { create(:project, :public, group: subgroup)}
let!(:issue) { create(:issue, project: project, title: 'root group issue') }
let!(:subgroup_issue) { create(:issue, project: subgroup_project, title: 'subgroup issue') }
......@@ -59,5 +59,17 @@ feature 'Group issues page' do
expect(page).to have_content('subgroup issue')
end
end
context 'when project is archived' do
before do
project.archive!
end
it 'does not render issue' do
visit path
expect(page).not_to have_content issue.title[0..80]
end
end
end
end
......@@ -5,14 +5,14 @@ feature 'Group merge requests page' do
let(:path) { merge_requests_group_path(group) }
let(:issuable) { create(:merge_request, source_project: project, target_project: project, title: 'this is my created issuable') }
let(:access_level) { ProjectFeature::ENABLED }
let(:user) { user_in_group }
include_examples 'project features apply to issuables', MergeRequest
context 'archived issuable' do
let(:project_archived) { create(:project, :archived, :merge_requests_enabled, :repository, group: group) }
let(:issuable_archived) { create(:merge_request, source_project: project_archived, target_project: project_archived, title: 'issuable of an archived project') }
let(:access_level) { ProjectFeature::ENABLED }
let(:user) { user_in_group }
before do
issuable_archived
......@@ -36,9 +36,17 @@ feature 'Group merge requests page' do
end
end
context 'when merge request assignee to user' do
before do
issuable.update!(assignee: user)
visit path
end
it { expect(page).to have_content issuable.title[0..80] }
end
context 'group filtered search', :js do
let(:access_level) { ProjectFeature::ENABLED }
let(:user) { user_in_group }
let(:user2) { user_outside_group }
it 'filters by assignee only group users' do
......
......@@ -15,14 +15,44 @@ feature 'Group show page' do
end
it_behaves_like "an autodiscoverable RSS feed with current_user's RSS token"
context 'when group does not exist' do
let(:path) { group_path('not-exist') }
it { expect(status_code).to eq(404) }
end
end
context 'when signed out' do
before do
visit path
describe 'RSS' do
before do
visit path
end
it_behaves_like "an autodiscoverable RSS feed without an RSS token"
end
context 'when group has a public project', :js do
let!(:project) { create(:project, :public, namespace: group) }
it 'renders public project' do
visit path
expect(page).to have_link group.name
expect(page).to have_link project.name
end
end
it_behaves_like "an autodiscoverable RSS feed without an RSS token"
context 'when group has a private project', :js do
let!(:project) { create(:project, :private, namespace: group) }
it 'does not render private project' do
visit path
expect(page).to have_link group.name
expect(page).not_to have_link project.name
end
end
end
context 'subgroup support' do
......
require 'rails_helper'
describe 'User browse group projects page' do
let(:user) { create :user }
let(:group) { create :group }
context 'when user is owner' do
before do
group.add_owner(user)
end
context 'when user signed in' do
before do
sign_in(user)
end
context 'when group has archived project', :js do
let!(:project) { create :project, :archived, namespace: group }
it 'renders projects list' do
visit projects_group_path(group)
expect(page).to have_link project.name
expect(page).to have_xpath("//span[@class='label label-warning']", text: 'archived')
end
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment