|
22 | 22 | end |
23 | 23 |
|
24 | 24 | context "when creating a new refund reason" do |
25 | | - let(:query) { "?page=1&q%5Bname_or_description_cont%5D=Ret" } |
| 25 | + let(:query) { "?page=1&q%5Bname_or_code_cont%5D=Ret" } |
26 | 26 |
|
27 | 27 | before do |
28 | 28 | visit "/admin/refund_reasons/#{query}" |
|
44 | 44 | context "with valid data" do |
45 | 45 | it "successfully creates a new refund reason, keeping page and q params" do |
46 | 46 | fill_in "Name", with: "Return process" |
| 47 | + uncheck "Active" |
47 | 48 |
|
48 | 49 | click_on "Add Refund Reason" |
49 | 50 |
|
50 | 51 | expect(page).to have_content("Refund reason was successfully created.") |
| 52 | + click_on "Return process" |
| 53 | + expect(checkbox("Active")).not_to be_checked |
51 | 54 | expect(Spree::RefundReason.find_by(name: "Return process")).to be_present |
52 | 55 | expect(page.current_url).to include(query) |
53 | 56 | end |
|
64 | 67 | end |
65 | 68 |
|
66 | 69 | context "when editing an existing refund reason" do |
67 | | - let(:query) { "?page=1&q%5Bname_or_description_cont%5D=Ret" } |
| 70 | + let(:query) { "?page=1&q%5Bname_or_code_cont%5D=Ret" } |
68 | 71 |
|
69 | 72 | before do |
70 | | - Spree::RefundReason.create(name: "Return process") |
| 73 | + Spree::RefundReason.create(name: "Return process", active: false) |
71 | 74 | visit "/admin/refund_reasons#{query}" |
72 | 75 | click_on "Return process" |
73 | 76 | expect(page).to have_css("dialog") |
|
86 | 89 |
|
87 | 90 | it "successfully updates the existing refund reason" do |
88 | 91 | fill_in "Name", with: "Customer complaint" |
89 | | - |
| 92 | + check "Active" |
90 | 93 | click_on "Update Refund Reason" |
| 94 | + |
| 95 | + expect(page.current_url).to include(query) |
91 | 96 | expect(page).to have_content("Refund reason was successfully updated.") |
| 97 | + expect(page).to have_content("No Refund Reasons found") # search query still applied, filters out updated name |
| 98 | + clear_search |
| 99 | + |
92 | 100 | expect(page).to have_content("Customer complaint") |
93 | 101 | expect(page).not_to have_content("Return process") |
| 102 | + |
| 103 | + click_on "Customer complaint" |
| 104 | + expect(checkbox("Active")).to be_checked |
94 | 105 | expect(Spree::RefundReason.find_by(name: "Customer complaint")).to be_present |
95 | | - expect(page.current_url).to include(query) |
96 | 106 | end |
97 | 107 | end |
98 | 108 | end |
0 commit comments