Commit 2fabd1a1 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Change the order of tested methods in project_members_controller_spec

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 357c794a
...@@ -4,50 +4,6 @@ describe Projects::ProjectMembersController do ...@@ -4,50 +4,6 @@ describe Projects::ProjectMembersController do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:project, :public) } let(:project) { create(:project, :public) }
describe 'POST apply_import' do
let(:another_project) { create(:project, :private) }
let(:member) { create(:user) }
before do
project.team << [user, :master]
another_project.team << [member, :guest]
sign_in(user)
end
shared_context 'import applied' do
before do
post(:apply_import, namespace_id: project.namespace,
project_id: project,
source_project_id: another_project.id)
end
end
context 'when user can access source project members' do
before { another_project.team << [user, :guest] }
include_context 'import applied'
it 'imports source project members' do
expect(project.team_members).to include member
expect(response).to set_flash.to 'Successfully imported'
expect(response).to redirect_to(
namespace_project_project_members_path(project.namespace, project)
)
end
end
context 'when user is not member of a source project' do
include_context 'import applied'
it 'does not import team members' do
expect(project.team_members).not_to include member
end
it 'responds with not found' do
expect(response.status).to eq 404
end
end
end
describe 'GET index' do describe 'GET index' do
it 'renders index with 200 status code' do it 'renders index with 200 status code' do
get :index, namespace_id: project.namespace, project_id: project get :index, namespace_id: project.namespace, project_id: project
...@@ -228,4 +184,48 @@ describe Projects::ProjectMembersController do ...@@ -228,4 +184,48 @@ describe Projects::ProjectMembersController do
end end
end end
end end
describe 'POST apply_import' do
let(:another_project) { create(:project, :private) }
let(:member) { create(:user) }
before do
project.team << [user, :master]
another_project.team << [member, :guest]
sign_in(user)
end
shared_context 'import applied' do
before do
post(:apply_import, namespace_id: project.namespace,
project_id: project,
source_project_id: another_project.id)
end
end
context 'when user can access source project members' do
before { another_project.team << [user, :guest] }
include_context 'import applied'
it 'imports source project members' do
expect(project.team_members).to include member
expect(response).to set_flash.to 'Successfully imported'
expect(response).to redirect_to(
namespace_project_project_members_path(project.namespace, project)
)
end
end
context 'when user is not member of a source project' do
include_context 'import applied'
it 'does not import team members' do
expect(project.team_members).not_to include member
end
it 'responds with not found' do
expect(response.status).to eq 404
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