Skip to content

Commit

Permalink
Test requests with reviews for packages and projects
Browse files Browse the repository at this point in the history
  • Loading branch information
danidoni committed Dec 18, 2024
1 parent a47615d commit 848c7c2
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@
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_package requests' do
let(:target_project) { create(:project_with_package) }
let(:target_package) { target_project.packages.first }
Expand All @@ -45,15 +39,28 @@
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
Expand All @@ -63,6 +70,7 @@
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
Expand All @@ -72,6 +80,19 @@
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

xcontext 'when filtering by the request text' do
let(:context_params) { { requests_search_text: 'something' } }

before do
allow(ThinkingSphinx).to receive(:search).and_return(["Fake result with #{package.name}"])
end

it { expect(response).to have_http_status(:success) }
it { expect(subject).to render_template(:index) }
it { expect(assigns[:bs_requests]).to be_empty }
end
end

Expand All @@ -92,15 +113,28 @@
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

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

context 'and the direction parameters is "outgoing"' do
Expand All @@ -110,6 +144,7 @@
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
Expand All @@ -119,6 +154,7 @@
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@
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) }
let(:target_package) { target_project.packages.first }
Expand All @@ -45,15 +39,28 @@
source_package: target_package,
target_package: create(:project))
end
let!(:request_with_review) do
create(:bs_request_with_submit_action,
review_by_project: target_project,
creator: user,
priority: 'critical')
end
let(:base_params) { { project: target_project, 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
Expand All @@ -63,6 +70,7 @@
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
Expand All @@ -72,6 +80,7 @@
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

Expand All @@ -92,15 +101,28 @@
source_package: source_package,
target_package: create(:project))
end
let!(:request_with_review) do
create(:bs_request_with_submit_action,
review_by_project: source_project,
creator: user,
priority: 'critical')
end
let(:base_params) { { project: source_project, 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]).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

context 'and the direction parameters is "outgoing"' do
Expand All @@ -110,6 +132,7 @@
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
Expand All @@ -119,6 +142,7 @@
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
Expand Down

0 comments on commit 848c7c2

Please sign in to comment.