Commit d15fb4cc authored by Felipe Artur's avatar Felipe Artur

Fix TestCasesController permission inconsistency

parent 0d347294
...@@ -5,7 +5,7 @@ class Projects::Quality::TestCasesController < Projects::ApplicationController ...@@ -5,7 +5,7 @@ class Projects::Quality::TestCasesController < Projects::ApplicationController
before_action :check_quality_management_available! before_action :check_quality_management_available!
before_action :authorize_read_issue! before_action :authorize_read_issue!
before_action :authorize_create_issue!, only: [:new] before_action :authorize_admin_issue!, only: [:new]
feature_category :quality_management feature_category :quality_management
......
...@@ -4,13 +4,14 @@ require 'spec_helper' ...@@ -4,13 +4,14 @@ require 'spec_helper'
RSpec.describe Projects::Quality::TestCasesController do RSpec.describe Projects::Quality::TestCasesController do
let_it_be(:project) { create(:project) } let_it_be(:project) { create(:project) }
let_it_be(:user) { create(:user) } let_it_be(:non_member) { create(:user) }
let_it_be(:guest) { create(:project_member, :guest, project: project).user }
let_it_be(:reporter) { create(:project_member, :reporter, project: project).user }
shared_examples_for 'test case action' do |template| shared_examples_for 'test case action' do |template|
context 'with authorized user' do context 'with authorized user' do
before do before do
project.add_developer(user) sign_in(authorized_user)
sign_in(user)
end end
context 'when feature is available' do context 'when feature is available' do
...@@ -41,7 +42,7 @@ RSpec.describe Projects::Quality::TestCasesController do ...@@ -41,7 +42,7 @@ RSpec.describe Projects::Quality::TestCasesController do
context 'with unauthorized user' do context 'with unauthorized user' do
before do before do
sign_in(user) sign_in(unauthorized_user)
end end
context 'when feature is available' do context 'when feature is available' do
...@@ -69,18 +70,26 @@ RSpec.describe Projects::Quality::TestCasesController do ...@@ -69,18 +70,26 @@ RSpec.describe Projects::Quality::TestCasesController do
describe 'GET' do describe 'GET' do
describe '#index' do describe '#index' do
let_it_be(:authorized_user) { guest }
let_it_be(:unauthorized_user) { non_member }
subject { get :index, params: { namespace_id: project.namespace, project_id: project } } subject { get :index, params: { namespace_id: project.namespace, project_id: project } }
it_behaves_like 'test case action', :index it_behaves_like 'test case action', :index
end end
describe '#new' do describe '#new' do
let_it_be(:authorized_user) { reporter }
let_it_be(:unauthorized_user) { guest }
subject { get :new, params: { namespace_id: project.namespace, project_id: project } } subject { get :new, params: { namespace_id: project.namespace, project_id: project } }
it_behaves_like 'test case action', :new it_behaves_like 'test case action', :new
end end
describe '#show' do describe '#show' do
let_it_be(:authorized_user) { guest }
let_it_be(:unauthorized_user) { non_member }
let_it_be(:test_case) { create(:quality_test_case, project: project) } let_it_be(:test_case) { create(:quality_test_case, project: project) }
subject { get :show, params: { namespace_id: project.namespace, project_id: project, id: test_case } } subject { get :show, params: { namespace_id: project.namespace, project_id: project, id: test_case } }
...@@ -90,8 +99,7 @@ RSpec.describe Projects::Quality::TestCasesController do ...@@ -90,8 +99,7 @@ RSpec.describe Projects::Quality::TestCasesController do
context 'when feature is enabled and user has access' do context 'when feature is enabled and user has access' do
before do before do
stub_licensed_features(quality_management: true) stub_licensed_features(quality_management: true)
project.add_developer(user) sign_in(authorized_user)
sign_in(user)
end end
it 'assigns test case related variables' do it 'assigns test case related variables' do
......
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