|
30 | 30 | create(:request, :with_item_requests, :pending, partner: partner1, request_items: [{ "item_id": item1.id, "quantity": '16' }]) |
31 | 31 | end |
32 | 32 |
|
33 | | - it "excludes cancelled requests by default" do |
| 33 | + it "lists requests" do |
34 | 34 | visit subject |
35 | | - |
36 | | - expect(find_field("include_cancelled")).not_to be_checked |
37 | | - |
38 | 35 | expect(page).to have_xpath("//h1", text: "Requests") |
39 | | - expect(page.find("table")).to have_content('Started', count: 3) |
40 | | - expect(page.find("table")).to have_content('Fulfilled', count: 1) |
41 | | - expect(page.find("table")).to have_content('Pending', count: 1) |
42 | 36 | end |
43 | 37 |
|
44 | | - context "when 'Include Cancelled?' is checked" do |
45 | | - it 'does not display the Cancel button for cancelled requests' do |
46 | | - _cancelled_request = create(:request, :with_item_requests, :cancelled, partner: partner1, request_items: [{ "item_id": item1.id, "quantity": '6' }]) |
| 38 | + it "can be exported in CSV" do |
| 39 | + visit subject |
| 40 | + click_on "Export Requests" |
47 | 41 |
|
48 | | - visit subject |
| 42 | + wait_for_download |
| 43 | + expect(downloads.length).to eq(1) |
| 44 | + expect(download).to match(/.*\.csv/) |
49 | 45 |
|
50 | | - check "Include Cancelled?" |
51 | | - click_on 'Filter' |
| 46 | + headers, *rows = download_content.split("\n") |
52 | 47 |
|
53 | | - within "table tbody" do |
54 | | - expect(page).to have_content("Cancelled", count: 1) |
55 | | - expect(page).to have_link("Cancel", count: 5) # 5 requests created in the before block |
56 | | - end |
57 | | - end |
58 | | - end |
59 | | - |
60 | | - context "exporting requests" do |
61 | | - it "exports the requests CSV excluding cancelled requests by default" do |
62 | | - _cancelled_request = create(:request, :with_item_requests, :cancelled, partner: partner1, request_items: [{ "item_id": item1.id, "quantity": '6' }]) |
63 | | - |
64 | | - visit subject |
65 | | - click_on "Export Requests" |
66 | | - |
67 | | - wait_for_download |
68 | | - expect(downloads.length).to eq(1) |
69 | | - expect(download).to match(/.*\.csv/) |
70 | | - |
71 | | - headers, *rows = download_content.split("\n") |
72 | | - |
73 | | - expect(rows.size).to eq(5) |
74 | | - expect(rows.join).to have_text(partner1.name, count: 4) |
75 | | - expect(rows.join).not_to have_text('Cancelled') |
76 | | - expect(headers).to have_text(item2.name, count: 1) |
77 | | - end |
78 | | - |
79 | | - it "exports the requests CSV including cancelled requests when 'Include Cancelled' is checked" do |
80 | | - _cancelled_request = create(:request, :with_item_requests, :cancelled, partner: partner1, request_items: [{ "item_id": item1.id, "quantity": '6' }]) |
81 | | - |
82 | | - visit subject |
83 | | - check "Include Cancelled?" |
84 | | - click_on 'Filter' |
85 | | - |
86 | | - click_on "Export Requests" |
87 | | - |
88 | | - wait_for_download |
89 | | - expect(downloads.length).to eq(1) |
90 | | - expect(download).to match(/.*\.csv/) |
91 | | - |
92 | | - headers, *rows = download_content.split("\n") |
93 | | - |
94 | | - expect(rows.size).to eq(6) |
95 | | - expect(rows.join).to have_text(partner1.name, count: 5) |
96 | | - expect(rows.join).to have_text('Cancelled') |
97 | | - expect(headers).to have_text(item2.name, count: 1) |
98 | | - end |
| 48 | + expect(rows.size).to eq(5) |
| 49 | + expect(rows.join).to have_text(partner1.name, count: 4) |
| 50 | + expect(headers).to have_text(item2.name, count: 1) |
99 | 51 | end |
100 | 52 |
|
101 | 53 | context "when filtering on the index page" do |
|
160 | 112 | expect(rows.join).to have_text('13', count: 1) |
161 | 113 | expect(rows.join).to have_text(partner1.name, count: 1) |
162 | 114 | end |
163 | | - |
164 | | - it "exports only the cancelled requests CSV when 'Include Cancelled' is checked and 'Filter by Status' is 'Cancelled'" do |
165 | | - _cancelled_request = create(:request, :with_item_requests, :cancelled, partner: partner1, request_items: [{ "item_id": item1.id, "quantity": '6' }]) |
166 | | - |
167 | | - visit subject |
168 | | - check "Include Cancelled?" |
169 | | - select "Cancelled", from: "Filter by status" |
170 | | - click_on 'Filter' |
171 | | - |
172 | | - click_on "Export Requests" |
173 | | - |
174 | | - wait_for_download |
175 | | - expect(downloads.length).to eq(1) |
176 | | - expect(download).to match(/.*\.csv/) |
177 | | - |
178 | | - headers, *rows = download_content.split("\n") |
179 | | - |
180 | | - expect(rows.size).to eq(1) |
181 | | - expect(rows.join).to have_text(partner1.name, count: 1) |
182 | | - expect(rows.join).to have_text('Cancelled') |
183 | | - expect(headers).to have_text(item1.name, count: 1) |
184 | | - end |
185 | 115 | end |
186 | 116 | end |
187 | 117 |
|
|
278 | 208 | expect(page).to have_content("334") |
279 | 209 | end |
280 | 210 |
|
281 | | - context 'when the request has a cancelled status' do |
282 | | - it 'does not display the Cancel and Fulfill request buttons' do |
283 | | - cancelled_request = create(:request, :with_item_requests, :cancelled, organization: organization) |
284 | | - |
285 | | - visit request_path(cancelled_request.id) |
286 | | - |
287 | | - expect(page).to have_content('Cancelled') |
288 | | - expect(page).not_to have_button('Cancel') |
289 | | - expect(page).not_to have_button('Fulfill request') |
290 | | - expect(page).to have_content('Print') |
291 | | - end |
292 | | - end |
293 | | - |
294 | 211 | context "change status request" do |
295 | 212 | before do |
296 | 213 | visit subject |
|
0 commit comments