|
20 | 20 | expect(page).not_to have_selector("select.default-select")
|
21 | 21 | expect(page).not_to have_selector("select.select2")
|
22 | 22 | end
|
| 23 | + |
| 24 | + context "with tags: true option" do |
| 25 | + let(:invoice) { create_invoice } |
| 26 | + let(:selection) { '#444' } |
| 27 | + |
| 28 | + before do |
| 29 | + register_form(Invoice) do |f| |
| 30 | + f.input :number, as: :select, collection: ["#111", "#222", "#333"], tags: true |
| 31 | + end |
| 32 | + end |
| 33 | + |
| 34 | + context 'when entering option not in collection' do |
| 35 | + before { visit edit_admin_invoice_path(invoice) } |
| 36 | + |
| 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) |
| 41 | + end |
| 42 | + end |
| 43 | + end |
| 44 | + |
| 45 | + context "with tags: false option" do |
| 46 | + let(:selection) { '#444' } |
| 47 | + |
| 48 | + before do |
| 49 | + register_form(Invoice) do |f| |
| 50 | + f.input :number, as: :select, collection: ["#111", "#222", "#333"], tags: false |
| 51 | + end |
| 52 | + end |
| 53 | + |
| 54 | + context 'when entering option not in collection' do |
| 55 | + let(:selection) { '#444' } |
| 56 | + |
| 57 | + before { visit edit_admin_invoice_path(create_invoice) } |
| 58 | + |
| 59 | + it "doesn't add new option", js: true do |
| 60 | + expect_select2_options_count_to_eq(4) |
| 61 | + fill_select2_input(selection) |
| 62 | + expect_select2_options_count_to_eq(4) |
| 63 | + end |
| 64 | + end |
| 65 | + end |
23 | 66 | end
|
24 | 67 |
|
25 | 68 | context "when default config is select 2 and select control has default-select class" do
|
|
0 commit comments