Commit 68c730bb authored by Jose Ivan Vargas's avatar Jose Ivan Vargas

Fixed rspec tests for the project members also fixed the index

view (removed an extra tag )
parent 4cd139e9
...@@ -6,48 +6,7 @@ class Projects::ProjectMembersController < Projects::ApplicationController ...@@ -6,48 +6,7 @@ class Projects::ProjectMembersController < Projects::ApplicationController
before_action :authorize_admin_project_member!, except: [:index, :leave, :request_access] before_action :authorize_admin_project_member!, except: [:index, :leave, :request_access]
def index def index
@sort = params[:sort].presence || sort_value_name redirect_to namespace_project_settings_members_path(@project.namespace, @project)
@group_links = @project.project_group_links
@project_members = @project.project_members
@project_members = @project_members.non_invite unless can?(current_user, :admin_project, @project)
group = @project.group
if group
# We need `.where.not(user_id: nil)` here otherwise when a group has an
# invitee, it would make the following query return 0 rows since a NULL
# user_id would be present in the subquery
# See http://stackoverflow.com/questions/129077/not-in-clause-and-null-values
# FIXME: This whole logic should be moved to a finder!
non_null_user_ids = @project_members.where.not(user_id: nil).select(:user_id)
group_members = group.group_members.where.not(user_id: non_null_user_ids)
group_members = group_members.non_invite unless can?(current_user, :admin_group, @group)
end
if params[:search].present?
user_ids = @project.users.search(params[:search]).select(:id)
@project_members = @project_members.where(user_id: user_ids)
if group_members
user_ids = group.users.search(params[:search]).select(:id)
group_members = group_members.where(user_id: user_ids)
end
@group_links = @project.project_group_links.where(group_id: @project.invited_groups.search(params[:search]).select(:id))
end
wheres = ["members.id IN (#{@project_members.select(:id).to_sql})"]
wheres << "members.id IN (#{group_members.select(:id).to_sql})" if group_members
@project_members = Member.
where(wheres.join(' OR ')).
sort(@sort).
page(params[:page])
@requesters = AccessRequestsFinder.new(@project).execute(current_user)
@project_member = @project.project_members.new
end end
def create def create
......
...@@ -17,11 +17,7 @@ ...@@ -17,11 +17,7 @@
%h5.member.existing-title %h5.member.existing-title
Existing users and groups Existing users and groups
- if @group_links.any? - if @group_links.any?
= render 'groups', group_links: @group_links = render 'projects/project_members/groups', group_links: @group_links
.append-bottom-default.clearfix
- if @group_links.any?
= render 'groups', group_links: @group_links
= render 'projects/project_members/team', members: @project_members = render 'projects/project_members/team', members: @project_members
= paginate @project_members, theme: "gitlab" = paginate @project_members, theme: "gitlab"
= form_for @project_member, as: :project_member, url: namespace_project_settings_members_path(@project.namespace, @project), html: { class: 'users-project-form' } do |f| = form_for @project_member, as: :project_member, url: namespace_project_project_members_path(@project.namespace, @project), html: { class: 'users-project-form' } do |f|
.row .row
.col-md-5.col-lg-5 .col-md-5.col-lg-5
= users_select_tag(:user_ids, multiple: true, class: "input-clamp", scope: :all, email_user: true) = users_select_tag(:user_ids, multiple: true, class: "input-clamp", scope: :all, email_user: true)
......
...@@ -5,11 +5,11 @@ describe Projects::ProjectMembersController do ...@@ -5,11 +5,11 @@ describe Projects::ProjectMembersController do
let(:project) { create(:empty_project, :public, :access_requestable) } let(:project) { create(:empty_project, :public, :access_requestable) }
describe 'GET index' do describe 'GET index' do
it 'renders index with 200 status code' do it 'redirects to settings/members with 302 status code' do
get :index, namespace_id: project.namespace, project_id: project get :index, namespace_id: project.namespace, project_id: project
expect(response).to have_http_status(200) expect(response).to have_http_status(302)
expect(response).to render_template(:index) expect(response).to redirect_to(namespace_project_settings_members_path(project.namespace, project))
end end
end end
...@@ -44,7 +44,7 @@ describe Projects::ProjectMembersController do ...@@ -44,7 +44,7 @@ describe Projects::ProjectMembersController do
access_level: Gitlab::Access::GUEST access_level: Gitlab::Access::GUEST
expect(response).to set_flash.to 'Users were successfully added.' expect(response).to set_flash.to 'Users were successfully added.'
expect(response).to redirect_to(namespace_project_project_members_path(project.namespace, project)) expect(response).to redirect_to(namespace_project_settings_members_path(project.namespace, project))
end end
it 'adds no user to members' do it 'adds no user to members' do
...@@ -56,7 +56,7 @@ describe Projects::ProjectMembersController do ...@@ -56,7 +56,7 @@ describe Projects::ProjectMembersController do
access_level: Gitlab::Access::GUEST access_level: Gitlab::Access::GUEST
expect(response).to set_flash.to 'No users or groups specified.' expect(response).to set_flash.to 'No users or groups specified.'
expect(response).to redirect_to(namespace_project_project_members_path(project.namespace, project)) expect(response).to redirect_to(namespace_project_settings_members_path(project.namespace, project))
end end
end end
end end
...@@ -99,7 +99,7 @@ describe Projects::ProjectMembersController do ...@@ -99,7 +99,7 @@ describe Projects::ProjectMembersController do
id: member id: member
expect(response).to redirect_to( expect(response).to redirect_to(
namespace_project_project_members_path(project.namespace, project) namespace_project_settings_members_path(project.namespace, project)
) )
expect(project.members).not_to include member expect(project.members).not_to include member
end end
...@@ -259,7 +259,7 @@ describe Projects::ProjectMembersController do ...@@ -259,7 +259,7 @@ describe Projects::ProjectMembersController do
expect(project.team_members).to include member expect(project.team_members).to include member
expect(response).to set_flash.to 'Successfully imported' expect(response).to set_flash.to 'Successfully imported'
expect(response).to redirect_to( expect(response).to redirect_to(
namespace_project_project_members_path(project.namespace, project) namespace_project_settings_members_path(project.namespace, project)
) )
end end
end end
......
...@@ -11,10 +11,10 @@ feature 'Projects > Members > Anonymous user sees members', feature: true do ...@@ -11,10 +11,10 @@ feature 'Projects > Members > Anonymous user sees members', feature: true do
end end
scenario "anonymous user visits the project's members page and sees the list of members" do scenario "anonymous user visits the project's members page and sees the list of members" do
visit namespace_project_project_members_path(project.namespace, project) visit namespace_project_settings_members_path(project.namespace, project)
expect(current_path).to eq( expect(current_path).to eq(
namespace_project_project_members_path(project.namespace, project)) namespace_project_settings_members_path(project.namespace, project))
expect(page).to have_content(user.name) expect(page).to have_content(user.name)
end end
end end
...@@ -19,7 +19,7 @@ feature 'Projects members', feature: true do ...@@ -19,7 +19,7 @@ feature 'Projects members', feature: true do
context 'with a group invitee' do context 'with a group invitee' do
before do before do
group_invitee group_invitee
visit namespace_project_project_members_path(project.namespace, project) visit namespace_project_settings_members_path(project.namespace, project)
end end
scenario 'does not appear in the project members page' do scenario 'does not appear in the project members page' do
...@@ -33,7 +33,7 @@ feature 'Projects members', feature: true do ...@@ -33,7 +33,7 @@ feature 'Projects members', feature: true do
before do before do
group_invitee group_invitee
project_invitee project_invitee
visit namespace_project_project_members_path(project.namespace, project) visit namespace_project_settings_members_path(project.namespace, project)
end end
scenario 'shows the project invitee, the project developer, and the group owner' do scenario 'shows the project invitee, the project developer, and the group owner' do
...@@ -54,7 +54,7 @@ feature 'Projects members', feature: true do ...@@ -54,7 +54,7 @@ feature 'Projects members', feature: true do
context 'with a group requester' do context 'with a group requester' do
before do before do
group.request_access(group_requester) group.request_access(group_requester)
visit namespace_project_project_members_path(project.namespace, project) visit namespace_project_settings_members_path(project.namespace, project)
end end
scenario 'does not appear in the project members page' do scenario 'does not appear in the project members page' do
...@@ -68,7 +68,7 @@ feature 'Projects members', feature: true do ...@@ -68,7 +68,7 @@ feature 'Projects members', feature: true do
before do before do
group.request_access(group_requester) group.request_access(group_requester)
project.request_access(project_requester) project.request_access(project_requester)
visit namespace_project_project_members_path(project.namespace, project) visit namespace_project_settings_members_path(project.namespace, project)
end end
scenario 'shows the project requester, the project developer, and the group owner' do scenario 'shows the project requester, the project developer, and the group owner' do
......
...@@ -16,7 +16,8 @@ feature 'Projects > Members > Master adds member with expiration date', feature: ...@@ -16,7 +16,8 @@ feature 'Projects > Members > Master adds member with expiration date', feature:
scenario 'expiration date is displayed in the members list' do scenario 'expiration date is displayed in the members list' do
travel_to Time.zone.parse('2016-08-06 08:00') do travel_to Time.zone.parse('2016-08-06 08:00') do
visit namespace_project_project_members_path(project.namespace, project) visit namespace_project_settings_members_path(project.namespace, project)
save_screenshot
page.within '.users-project-form' do page.within '.users-project-form' do
select2(new_member.id, from: '#user_ids', multiple: true) select2(new_member.id, from: '#user_ids', multiple: true)
......
...@@ -82,8 +82,8 @@ describe "Internal Project Access", feature: true do ...@@ -82,8 +82,8 @@ describe "Internal Project Access", feature: true do
it { is_expected.to be_denied_for(:visitor) } it { is_expected.to be_denied_for(:visitor) }
end end
describe "GET /:project_path/project_members" do describe "GET /:project_path/settings/project_members" do
subject { namespace_project_project_members_path(project.namespace, project) } subject { namespace_project_settings_members_path(project.namespace, project) }
it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
......
...@@ -82,8 +82,8 @@ describe "Private Project Access", feature: true do ...@@ -82,8 +82,8 @@ describe "Private Project Access", feature: true do
it { is_expected.to be_denied_for(:visitor) } it { is_expected.to be_denied_for(:visitor) }
end end
describe "GET /:project_path/project_members" do describe "GET /:project_path/settings/project_members" do
subject { namespace_project_project_members_path(project.namespace, project) } subject { namespace_project_settings_members_path(project.namespace, project) }
it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
......
...@@ -82,8 +82,8 @@ describe "Public Project Access", feature: true do ...@@ -82,8 +82,8 @@ describe "Public Project Access", feature: true do
it { is_expected.to be_allowed_for(:visitor) } it { is_expected.to be_allowed_for(:visitor) }
end end
describe "GET /:project_path/project_members" do describe "GET /:project_path/settings/project_members" do
subject { namespace_project_project_members_path(project.namespace, project) } subject { namespace_project_settings_members_path(project.namespace, project) }
it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) } it { is_expected.to be_allowed_for(:owner).of(project) }
......
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