|
5 | 5 | require 'support/active_admin_helpers' |
6 | 6 |
|
7 | 7 | RSpec.describe 'end to end', type: :feature, js: true do |
8 | | - before(:each) do |
9 | | - ActiveAdminHelpers.setup do |
10 | | - ActiveAdmin.register(Category) do |
11 | | - searchable_select_options(scope: Category, text_attribute: :name) |
12 | | - end |
| 8 | + context 'class name without namespaces' do |
| 9 | + before(:each) do |
| 10 | + ActiveAdminHelpers.setup do |
| 11 | + ActiveAdmin.register(Category) do |
| 12 | + searchable_select_options(scope: Category, text_attribute: :name) |
| 13 | + end |
13 | 14 |
|
14 | | - ActiveAdmin.register(Post) do |
15 | | - filter(:category, as: :searchable_select, ajax: true) |
| 15 | + ActiveAdmin.register(Post) do |
| 16 | + filter(:category, as: :searchable_select, ajax: true) |
16 | 17 |
|
17 | | - form do |f| |
18 | | - f.input(:category, as: :searchable_select, ajax: true) |
| 18 | + form do |f| |
| 19 | + f.input(:category, as: :searchable_select, ajax: true) |
| 20 | + end |
19 | 21 | end |
20 | | - end |
21 | 22 |
|
22 | | - ActiveAdmin.setup {} |
| 23 | + ActiveAdmin.setup {} |
| 24 | + end |
23 | 25 | end |
24 | | - end |
25 | 26 |
|
26 | | - describe 'index page with searchable select filter' do |
27 | | - it 'loads filter input options' do |
28 | | - Category.create(name: 'Music') |
29 | | - Category.create(name: 'Travel') |
| 27 | + describe 'index page with searchable select filter' do |
| 28 | + it 'loads filter input options' do |
| 29 | + Category.create(name: 'Music') |
| 30 | + Category.create(name: 'Travel') |
30 | 31 |
|
31 | | - visit '/admin/posts' |
| 32 | + visit '/admin/posts' |
32 | 33 |
|
33 | | - expand_select_box |
34 | | - wait_for_ajax |
| 34 | + expand_select_box |
| 35 | + wait_for_ajax |
35 | 36 |
|
36 | | - expect(select_box_items).to eq(%w(Music Travel)) |
37 | | - end |
| 37 | + expect(select_box_items).to eq(%w(Music Travel)) |
| 38 | + end |
| 39 | + |
| 40 | + it 'allows filtering options by term' do |
| 41 | + Category.create(name: 'Music') |
| 42 | + Category.create(name: 'Travel') |
| 43 | + |
| 44 | + visit '/admin/posts' |
| 45 | + |
| 46 | + expand_select_box |
| 47 | + enter_search_term('T') |
| 48 | + wait_for_ajax |
| 49 | + |
| 50 | + expect(select_box_items).to eq(%w(Travel)) |
| 51 | + end |
| 52 | + |
| 53 | + it 'loads more items when scrolling down' do |
| 54 | + 15.times { |i| Category.create(name: "Category #{i}") } |
| 55 | + visit '/admin/posts' |
38 | 56 |
|
39 | | - it 'allows filtering options by term' do |
40 | | - Category.create(name: 'Music') |
41 | | - Category.create(name: 'Travel') |
| 57 | + expand_select_box |
| 58 | + wait_for_ajax |
| 59 | + scroll_select_box_list |
| 60 | + wait_for_ajax |
42 | 61 |
|
43 | | - visit '/admin/posts' |
| 62 | + expect(select_box_items.size).to eq(15) |
| 63 | + end |
| 64 | + end |
| 65 | + end |
44 | 66 |
|
45 | | - expand_select_box |
46 | | - enter_search_term('T') |
47 | | - wait_for_ajax |
| 67 | + context 'class name with namespace' do |
| 68 | + before(:each) do |
| 69 | + ActiveAdminHelpers.setup do |
| 70 | + ActiveAdmin.register RGB::Color, as: 'color' do |
| 71 | + searchable_select_options scope: RGB::Color, text_attribute: :code |
| 72 | + end |
48 | 73 |
|
49 | | - expect(select_box_items).to eq(%w(Travel)) |
| 74 | + ActiveAdmin.register Internal::TagName, as: 'Tag Name' do |
| 75 | + filter :color, as: :searchable_select, ajax: { resource: RGB::Color } |
| 76 | + end |
| 77 | + |
| 78 | + ActiveAdmin.setup {} |
| 79 | + end |
50 | 80 | end |
51 | 81 |
|
52 | | - it 'loads more items when scrolling down' do |
53 | | - 15.times { |i| Category.create(name: "Category #{i}") } |
54 | | - visit '/admin/posts' |
| 82 | + describe 'index page with searchable select filter' do |
| 83 | + it 'loads filter input options' do |
| 84 | + RGB::Color.create(code: '#eac112', description: 'Orange') |
| 85 | + RGB::Color.create(code: '#19bf25', description: 'Green') |
55 | 86 |
|
56 | | - expand_select_box |
57 | | - wait_for_ajax |
58 | | - scroll_select_box_list |
59 | | - wait_for_ajax |
| 87 | + visit '/admin/tag_names' |
60 | 88 |
|
61 | | - expect(select_box_items.size).to eq(15) |
| 89 | + expand_select_box |
| 90 | + wait_for_ajax |
| 91 | + |
| 92 | + expect(select_box_items).to eq(%w(#eac112 #19bf25)) |
| 93 | + end |
62 | 94 | end |
63 | 95 | end |
64 | 96 |
|
|
0 commit comments