Skip to content

Commit

Permalink
Refactor webui project requests controller specs
Browse files Browse the repository at this point in the history
  • Loading branch information
danidoni committed Dec 16, 2024
1 parent 84e20b8 commit ffdfbe7
Showing 1 changed file with 11 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@

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) }

before do
login user
Flipper.enable(:request_index, user)
get :index, params: params, format: :html
end

context 'when looking at the target_projects requests' do
let(:target_project) { create(:project_with_package) }
Expand All @@ -38,32 +45,19 @@
source_package: target_package,
target_package: create(:project))
end
let(:base_params) { { project: target_project, format: :json } }

context 'and the direction parameters is "incoming"' do
let(:base_params) { { project: target_project, format: :json } }
let(:context_params) { { direction: 'incoming' } }
let(:params) { base_params.merge(context_params) }

before do
login user
Flipper.enable(:request_index, user)
get :index, params: params, format: :html
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) }
end

context 'and the direction parameters is "outgoing"' do
let(:base_params) { { project: target_project, format: :json } }
let(:context_params) { { direction: 'outgoing' } }
let(:params) { base_params.merge(context_params) }

before do
login user
Flipper.enable(:request_index, user)
get :index, params: params, format: :html
end

it { expect(response).to have_http_status(:success) }
it { expect(subject).to render_template(:index) }
Expand All @@ -72,15 +66,7 @@
end

context 'and the direction parameters is "all"' do
let(:base_params) { { project: target_project, format: :json } }
let(:context_params) { { direction: 'all' } }
let(:params) { base_params.merge(context_params) }

before do
login user
Flipper.enable(:request_index, user)
get :index, params: params, format: :html
end

it { expect(response).to have_http_status(:success) }
it { expect(subject).to render_template(:index) }
Expand All @@ -106,17 +92,10 @@
source_package: source_package,
target_package: create(:project))
end
let(:base_params) { { project: source_project, format: :json } }

context 'and the direction parameters is "incoming"' do
let(:base_params) { { project: source_project, format: :json } }
let(:context_params) { { direction: 'incoming' } }
let(:params) { base_params.merge(context_params) }

before do
login user
Flipper.enable(:request_index, user)
get :index, params: params, format: :html
end

it { expect(response).to have_http_status(:success) }
it { expect(subject).to render_template(:index) }
Expand All @@ -125,15 +104,7 @@
end

context 'and the direction parameters is "outgoing"' do
let(:base_params) { { project: source_project, format: :json } }
let(:context_params) { { direction: 'outgoing' } }
let(:params) { base_params.merge(context_params) }

before do
login user
Flipper.enable(:request_index, user)
get :index, params: params, format: :html
end

it { expect(response).to have_http_status(:success) }
it { expect(subject).to render_template(:index) }
Expand All @@ -142,15 +113,7 @@
end

context 'and the direction parameters is "all"' do
let(:base_params) { { project: source_project, format: :json } }
let(:context_params) { { direction: 'all' } }
let(:params) { base_params.merge(context_params) }

before do
login user
Flipper.enable(:request_index, user)
get :index, params: params, format: :html
end

it { expect(response).to have_http_status(:success) }
it { expect(subject).to render_template(:index) }
Expand Down

0 comments on commit ffdfbe7

Please sign in to comment.