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