2016-11-16 22:24:43 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-06-29 04:13:10 +00:00
|
|
|
feature 'Groups > Members > Sort members' do
|
2016-11-16 22:24:43 +00:00
|
|
|
let(:owner) { create(:user, name: 'John Doe') }
|
|
|
|
let(:developer) { create(:user, name: 'Mary Jane', last_sign_in_at: 5.days.ago) }
|
|
|
|
let(:group) { create(:group) }
|
|
|
|
|
|
|
|
background do
|
2016-11-22 21:10:31 +00:00
|
|
|
create(:group_member, :owner, user: owner, group: group, created_at: 5.days.ago)
|
|
|
|
create(:group_member, :developer, user: developer, group: group, created_at: 3.days.ago)
|
2016-11-16 22:24:43 +00:00
|
|
|
|
2017-06-21 23:44:10 +00:00
|
|
|
sign_in(owner)
|
2016-11-16 22:24:43 +00:00
|
|
|
end
|
|
|
|
|
2016-11-16 22:37:50 +00:00
|
|
|
scenario 'sorts alphabetically by default' do
|
|
|
|
visit_members_list(sort: nil)
|
|
|
|
|
|
|
|
expect(first_member).to include(owner.name)
|
|
|
|
expect(second_member).to include(developer.name)
|
2016-12-02 11:52:10 +00:00
|
|
|
expect(page).to have_css('.member-sort-dropdown .dropdown-toggle-text', text: 'Name, ascending')
|
2016-11-16 22:37:50 +00:00
|
|
|
end
|
|
|
|
|
2016-11-16 22:24:43 +00:00
|
|
|
scenario 'sorts by access level ascending' do
|
|
|
|
visit_members_list(sort: :access_level_asc)
|
|
|
|
|
|
|
|
expect(first_member).to include(developer.name)
|
|
|
|
expect(second_member).to include(owner.name)
|
2016-12-02 11:52:10 +00:00
|
|
|
expect(page).to have_css('.member-sort-dropdown .dropdown-toggle-text', text: 'Access level, ascending')
|
2016-11-16 22:24:43 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'sorts by access level descending' do
|
|
|
|
visit_members_list(sort: :access_level_desc)
|
|
|
|
|
|
|
|
expect(first_member).to include(owner.name)
|
|
|
|
expect(second_member).to include(developer.name)
|
2016-12-02 11:52:10 +00:00
|
|
|
expect(page).to have_css('.member-sort-dropdown .dropdown-toggle-text', text: 'Access level, descending')
|
2016-11-16 22:24:43 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'sorts by last joined' do
|
|
|
|
visit_members_list(sort: :last_joined)
|
|
|
|
|
|
|
|
expect(first_member).to include(developer.name)
|
|
|
|
expect(second_member).to include(owner.name)
|
2016-12-02 11:52:10 +00:00
|
|
|
expect(page).to have_css('.member-sort-dropdown .dropdown-toggle-text', text: 'Last joined')
|
2016-11-16 22:24:43 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'sorts by oldest joined' do
|
|
|
|
visit_members_list(sort: :oldest_joined)
|
|
|
|
|
|
|
|
expect(first_member).to include(owner.name)
|
|
|
|
expect(second_member).to include(developer.name)
|
2016-12-02 11:52:10 +00:00
|
|
|
expect(page).to have_css('.member-sort-dropdown .dropdown-toggle-text', text: 'Oldest joined')
|
2016-11-16 22:24:43 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'sorts by name ascending' do
|
|
|
|
visit_members_list(sort: :name_asc)
|
|
|
|
|
|
|
|
expect(first_member).to include(owner.name)
|
|
|
|
expect(second_member).to include(developer.name)
|
2016-12-02 11:52:10 +00:00
|
|
|
expect(page).to have_css('.member-sort-dropdown .dropdown-toggle-text', text: 'Name, ascending')
|
2016-11-16 22:24:43 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'sorts by name descending' do
|
|
|
|
visit_members_list(sort: :name_desc)
|
|
|
|
|
|
|
|
expect(first_member).to include(developer.name)
|
|
|
|
expect(second_member).to include(owner.name)
|
2016-12-02 11:52:10 +00:00
|
|
|
expect(page).to have_css('.member-sort-dropdown .dropdown-toggle-text', text: 'Name, descending')
|
2016-11-16 22:24:43 +00:00
|
|
|
end
|
|
|
|
|
2017-07-11 03:35:47 +00:00
|
|
|
scenario 'sorts by recent sign in', :clean_gitlab_redis_shared_state do
|
2016-11-16 22:24:43 +00:00
|
|
|
visit_members_list(sort: :recent_sign_in)
|
|
|
|
|
|
|
|
expect(first_member).to include(owner.name)
|
|
|
|
expect(second_member).to include(developer.name)
|
2016-12-02 11:52:10 +00:00
|
|
|
expect(page).to have_css('.member-sort-dropdown .dropdown-toggle-text', text: 'Recent sign in')
|
2016-11-16 22:24:43 +00:00
|
|
|
end
|
|
|
|
|
2017-07-11 03:35:47 +00:00
|
|
|
scenario 'sorts by oldest sign in', :clean_gitlab_redis_shared_state do
|
2016-11-16 22:24:43 +00:00
|
|
|
visit_members_list(sort: :oldest_sign_in)
|
|
|
|
|
|
|
|
expect(first_member).to include(developer.name)
|
|
|
|
expect(second_member).to include(owner.name)
|
2016-12-02 11:52:10 +00:00
|
|
|
expect(page).to have_css('.member-sort-dropdown .dropdown-toggle-text', text: 'Oldest sign in')
|
2016-11-16 22:24:43 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def visit_members_list(sort:)
|
|
|
|
visit group_group_members_path(group.to_param, sort: sort)
|
|
|
|
end
|
|
|
|
|
|
|
|
def first_member
|
|
|
|
page.all('ul.content-list > li').first.text
|
|
|
|
end
|
|
|
|
|
|
|
|
def second_member
|
|
|
|
page.all('ul.content-list > li').last.text
|
|
|
|
end
|
|
|
|
end
|