Skip to content

Commit

Permalink
Add spec to verify partner request view units [#4399]
Browse files Browse the repository at this point in the history
  • Loading branch information
awwaiid committed Jul 14, 2024
1 parent 2eeb51b commit 79902e3
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions spec/requests/partners/requests_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,37 @@
get partners_request_path(other_request)
expect(response.code).to eq("404")
end

it 'should show the units if they are provided and enabled' do
item1 = create(:item, name: "First item")
item2 = create(:item, name: "Second item")
item3 = create(:item, name: "Third item")
create(:item_unit, item: item1, name: "flat")
create(:item_unit, item: item2, name: "flat")
create(:item_unit, item: item3, name: "flat")
request = create(
:request,
partner_id: partner.id,
partner_user_id: partner_user.id,
request_items: [
{item_id: item1.id, quantity: '125'},
{item_id: item2.id, quantity: '559', request_unit: 'flat'},
{item_id: item3.id, quantity: '1', request_unit: 'flat'}
]
)

Flipper.enable(:enable_packs)
get partners_request_path(request)
expect(response.body).to match(/125\s+of\s+First item/m)
expect(response.body).to match(/559\s+flats\s+of\s+Second item/m)
expect(response.body).to match(/1\s+flat\s+of\s+Third item/m)

Flipper.disable(:enable_packs)
get partners_request_path(request)
expect(response.body).to match(/125\s+of\s+First item/m)
expect(response.body).to match(/559\s+of\s+Second item/m)
expect(response.body).to match(/1\s+of\s+Third item/m)
end
end

describe "POST #create" do
Expand Down

0 comments on commit 79902e3

Please sign in to comment.