diff --git a/src/api/spec/controllers/webui/packages/bs_requests_controller_spec.rb b/src/api/spec/controllers/webui/packages/bs_requests_controller_spec.rb index bb3721a8704..f0eb8b8c4a7 100644 --- a/src/api/spec/controllers/webui/packages/bs_requests_controller_spec.rb +++ b/src/api/spec/controllers/webui/packages/bs_requests_controller_spec.rb @@ -20,130 +20,64 @@ context 'when the user has the request_index feature flag enabled' do let!(:user) { create(:confirmed_user, login: 'king') } - let(:params) { base_params.merge(context_params) } - - context 'when looking at the target_package requests' do - let(:target_project) { create(:project_with_package) } - let(:target_package) { target_project.packages.first } - let!(:incoming_request) do - create(:bs_request_with_submit_action, - creator: user, - priority: 'critical', - source_package: create(:project), - target_package: target_package) - end - let!(:outgoing_request) do - create(:bs_request_with_submit_action, - creator: user, - priority: 'critical', - source_package: target_package, - target_package: create(:project)) - end - let!(:request_with_review) do - create(:bs_request_with_submit_action, - review_by_package: target_package, - creator: user, - priority: 'critical') - end - let(:base_params) { { project: target_project, package: target_package, format: :json } } - - before do - login user - Flipper.enable(:request_index, user) - get :index, params: params, format: :html - end - - context 'and the direction parameters is "incoming"' do - let(:context_params) { { direction: 'incoming' } } - - it { expect(response).to have_http_status(:success) } - it { expect(subject).to render_template(:index) } - it { expect(assigns[:bs_requests]).to include(incoming_request) } - it { expect(assigns[:bs_requests]).not_to include(outgoing_request) } - it { expect(assigns[:bs_requests]).not_to include(request_with_review) } - end - - context 'and the direction parameters is "outgoing"' do - let(:context_params) { { direction: 'outgoing' } } - - it { expect(response).to have_http_status(:success) } - it { expect(subject).to render_template(:index) } - it { expect(assigns[:bs_requests]).not_to include(incoming_request) } - it { expect(assigns[:bs_requests]).to include(outgoing_request) } - it { expect(assigns[:bs_requests]).not_to include(request_with_review) } - end - - context 'and the direction parameters is "all"' do - let(:context_params) { { direction: 'all' } } - - it { expect(response).to have_http_status(:success) } - it { expect(subject).to render_template(:index) } - it { expect(assigns[:bs_requests]).to include(incoming_request) } - it { expect(assigns[:bs_requests]).to include(outgoing_request) } - it { expect(assigns[:bs_requests]).to include(request_with_review) } - end + let(:a_project) { create(:project_with_package) } + let(:a_package) { a_project.packages.first } + let!(:incoming_request) do + create(:bs_request_with_submit_action, + creator: user, + priority: 'critical', + source_package: create(:project), + target_package: a_package) end + let!(:outgoing_request) do + create(:bs_request_with_submit_action, + creator: user, + priority: 'critical', + source_package: a_package, + target_package: create(:project)) + end + let!(:request_with_review) do + create(:bs_request_with_submit_action, + review_by_package: a_package, + creator: user, + priority: 'critical') + end + let(:base_params) { { project: a_project, package: a_package, format: :json } } - context 'when looking at the source_package requests' do - let(:source_project) { create(:project_with_package) } - let(:source_package) { source_project.packages.first } - let!(:incoming_request) do - create(:bs_request_with_submit_action, - creator: user, - priority: 'critical', - source_package: create(:project), - target_package: source_package) - end - let!(:outgoing_request) do - create(:bs_request_with_submit_action, - creator: user, - priority: 'critical', - source_package: source_package, - target_package: create(:project)) - end - let!(:request_with_review) do - create(:bs_request_with_submit_action, - review_by_package: source_package, - creator: user, - priority: 'critical') - end - let(:base_params) { { project: source_project, package: source_package, format: :json } } - - before do - login user - Flipper.enable(:request_index, user) - get :index, params: params, format: :html - end + before do + login user + Flipper.enable(:request_index, user) + get :index, params: base_params.merge(context_params), format: :html + end - context 'and the direction parameters is "incoming"' do - let(:context_params) { { direction: 'incoming' } } + context 'and the direction parameters is "incoming"' do + let(:context_params) { { direction: 'incoming' } } - it { expect(response).to have_http_status(:success) } - it { expect(subject).to render_template(:index) } - it { expect(assigns[:bs_requests]).not_to include(outgoing_request) } - it { expect(assigns[:bs_requests]).to include(incoming_request) } - it { expect(assigns[:bs_requests]).not_to include(request_with_review) } - end + it { expect(response).to have_http_status(:success) } + it { expect(subject).to render_template(:index) } + it { expect(assigns[:bs_requests]).to include(incoming_request) } + it { expect(assigns[:bs_requests]).not_to include(outgoing_request) } + it { expect(assigns[:bs_requests]).not_to include(request_with_review) } + end - context 'and the direction parameters is "outgoing"' do - let(:context_params) { { direction: 'outgoing' } } + context 'and the direction parameters is "outgoing"' do + let(:context_params) { { direction: 'outgoing' } } - it { expect(response).to have_http_status(:success) } - it { expect(subject).to render_template(:index) } - it { expect(assigns[:bs_requests]).not_to include(incoming_request) } - it { expect(assigns[:bs_requests]).to include(outgoing_request) } - it { expect(assigns[:bs_requests]).not_to include(request_with_review) } - end + it { expect(response).to have_http_status(:success) } + it { expect(subject).to render_template(:index) } + it { expect(assigns[:bs_requests]).not_to include(incoming_request) } + it { expect(assigns[:bs_requests]).to include(outgoing_request) } + it { expect(assigns[:bs_requests]).not_to include(request_with_review) } + end - context 'and the direction parameters is "all"' do - let(:context_params) { { direction: 'all' } } + context 'and the direction parameters is "all"' do + let(:context_params) { { direction: 'all' } } - it { expect(response).to have_http_status(:success) } - it { expect(subject).to render_template(:index) } - it { expect(assigns[:bs_requests]).to include(incoming_request) } - it { expect(assigns[:bs_requests]).to include(outgoing_request) } - it { expect(assigns[:bs_requests]).to include(request_with_review) } - end + it { expect(response).to have_http_status(:success) } + it { expect(subject).to render_template(:index) } + it { expect(assigns[:bs_requests]).to include(incoming_request) } + it { expect(assigns[:bs_requests]).to include(outgoing_request) } + it { expect(assigns[:bs_requests]).to include(request_with_review) } end end end