|
25 | 25 | let(:invoice) { create_invoice }
|
26 | 26 | let(:selection) { '#444' }
|
27 | 27 |
|
28 |
| - before do |
29 |
| - register_form(Invoice) do |f| |
30 |
| - f.input :number, as: :select, collection: ["#111", "#222", "#333"], tags: true |
| 28 | + context "with AA form" do |
| 29 | + before do |
| 30 | + register_form(Invoice) do |f| |
| 31 | + f.input :number, as: :select, collection: ["#111", "#222", "#333"], tags: true |
| 32 | + end |
31 | 33 | end
|
32 |
| - end |
33 | 34 |
|
34 |
| - context 'when entering option not in collection' do |
35 |
| - before { visit edit_admin_invoice_path(invoice) } |
| 35 | + context 'when entering option not in collection' do |
| 36 | + before { visit edit_admin_invoice_path(invoice) } |
36 | 37 |
|
37 |
| - it "adds new option", js: true do |
38 |
| - expect_select2_options_count_to_eq(4) |
39 |
| - fill_select2_input(selection) |
40 |
| - expect_select2_options_count_to_eq(5) |
| 38 | + it "adds new option", js: true do |
| 39 | + expect_select2_options_count_to_eq(4) |
| 40 | + fill_select2_input(selection) |
| 41 | + expect_select2_options_count_to_eq(5) |
| 42 | + end |
| 43 | + end |
| 44 | + |
| 45 | + context 'when initial value is not in inputs collection' do |
| 46 | + before do |
| 47 | + invoice.update!(number: selection) |
| 48 | + visit edit_admin_invoice_path(invoice) |
| 49 | + end |
| 50 | + |
| 51 | + it "includes initial value as option", js: true do |
| 52 | + expect_select2_options_count_to_eq(5) |
| 53 | + end |
41 | 54 | end
|
42 | 55 | end
|
43 | 56 |
|
44 |
| - context 'when initial value is not in inputs collection' do |
| 57 | + context "with custom form" do |
45 | 58 | before do
|
46 |
| - invoice.update!(number: selection) |
47 |
| - visit edit_admin_invoice_path(invoice) |
| 59 | + register_page(Invoice) do |
| 60 | + config.filters = false |
| 61 | + sidebar 'Filters' do |
| 62 | + active_admin_form_for(:q) do |f| |
| 63 | + f.input :number, as: :select, collection: ["#111", "#222", "#333"], tags: true |
| 64 | + end |
| 65 | + end |
| 66 | + end |
48 | 67 | end
|
49 | 68 |
|
50 |
| - it "includes initial value as option", js: true do |
51 |
| - expect_select2_options_count_to_eq(5) |
| 69 | + context 'when entering option not in collection' do |
| 70 | + before { visit admin_invoices_path } |
| 71 | + |
| 72 | + it "adds new option", js: true do |
| 73 | + expect_select2_options_count_to_eq(4) |
| 74 | + fill_select2_input(selection) |
| 75 | + expect_select2_options_count_to_eq(5) |
| 76 | + end |
52 | 77 | end
|
53 | 78 | end
|
54 | 79 | end
|
|
0 commit comments