activeadmin-searchable_select 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6a0f1ed4c7ca3f0b20a9a1844aa46ecf2693b5b91f447874cbfbc013d5a84e31
4
- data.tar.gz: cdca70eae83da1caf578f39957b66fe30cec69a76c67f7f06d2a45bb3c680f7d
3
+ metadata.gz: fe0935611dac081858397d808fa99c65a72944153ce323c8b10f3afb96657a83
4
+ data.tar.gz: e5c1faa951288612248a1f87f4ed1961f7f45861b7ac1946a404c5f15030f656
5
5
  SHA512:
6
- metadata.gz: b509e473b24b32cad8c401f197413c7b01c7de196aaf0a2a4a735f7f6bd40d4ea76ed7733f9b00f87ecf23e6d3aba0bceee599f85c4e39fb1a17639b4234d94f
7
- data.tar.gz: f224c6cc6fe60af0373b1d82c9d57a43282c3f327bf5c3c295d2b1d17ce5f9aace56aa0d4320405f40783a270fedaa8137496712091fc167712b9b1e1364a029
6
+ metadata.gz: '097917cab8c292dcf3cdab69661ff59f6a0377698514b6f7323b28a3a70bc2c3f66c41b64a7e26ae47f981559f791d6ae35df96ec1a736f214fcd7753cd25693'
7
+ data.tar.gz: 10592311d0cf0ad805abaf218ce97a9af4ff8a8350b861571465e01106815d6b3eaddd9641f2256e5323e5a05a6ed7cd0759a6531cdfe5af2cf858e69affedf2
data/.rubocop.yml CHANGED
@@ -1,5 +1,7 @@
1
1
  AllCops:
2
2
  TargetRubyVersion: 2.3
3
+ Exclude:
4
+ - 'bin/**/*'
3
5
 
4
6
  # The default of 80 characters is a little to narrow.
5
7
  Metrics/LineLength:
data/CHANGELOG.md CHANGED
@@ -1,20 +1,16 @@
1
1
  # CHANGELOG
2
2
 
3
- ### Version 1.3.0
3
+ ### Version 1.4.0
4
4
 
5
- 2021-02-03
5
+ 2021-02-04
6
6
 
7
- [Compare changes](https://github.com/codevise/activeadmin-searchable_select/compare/1-2-stable...v1.3.0)
7
+ [Compare changes](https://github.com/codevise/activeadmin-searchable_select/compare/1-3-stable...v1.4.0)
8
8
 
9
- - Add support for Ruby 3
10
- ([#26](https://github.com/codevise/activeadmin-searchable_select/pull/26))
11
- - Add a small description of how to pass options to Select2
12
- ([#27](https://github.com/codevise/activeadmin-searchable_select/pull/27))
13
- - Update CI Setup
14
- ([#25](https://github.com/codevise/activeadmin-searchable_select/pull/25))
15
- - Allow Bundler 2 in development dependencies
16
- ([#18](https://github.com/codevise/activeadmin-searchable_select/pull/18))
9
+ - Support admin resources for namespaced models.
10
+ ([#30](https://github.com/codevise/activeadmin-searchable_select/pull/30))
11
+ - Improve README.md
12
+ ([#28](https://github.com/codevise/activeadmin-searchable_select/pull/28))
17
13
 
18
14
  See
19
- [1-2-stable branch](https://github.com/codevise/activeadmin-searchable_select/blob/1-2-stable/CHANGELOG.md)
15
+ [1-3-stable branch](https://github.com/codevise/activeadmin-searchable_select/blob/1-3-stable/CHANGELOG.md)
20
16
  for previous changes.
data/README.md CHANGED
@@ -238,7 +238,7 @@ for feature specs:
238
238
  ```ruby
239
239
  RSpec.configure do |config|
240
240
  config.before(:each) do |example|
241
- ActiveAdmin::Select2.inline_ajax_options = (example.metadata[:type] == :feature)
241
+ ActiveAdmin::SearchableSelect.inline_ajax_options = (example.metadata[:type] == :feature)
242
242
  end
243
243
  end
244
244
 
@@ -45,9 +45,11 @@ module ActiveAdmin
45
45
 
46
46
  def ajax_url
47
47
  return unless options[:ajax]
48
- template.polymorphic_path([template.active_admin_namespace.route_prefix, ajax_resource_class],
49
- action: option_collection.collection_action_name,
50
- **ajax_params)
48
+ [ajax_resource.route_collection_path,
49
+ '/',
50
+ option_collection.collection_action_name,
51
+ '?',
52
+ ajax_params.to_query].join
51
53
  end
52
54
 
53
55
  def all_options_collection
@@ -1,5 +1,5 @@
1
1
  module ActiveAdmin
2
2
  module SearchableSelect
3
- VERSION = '1.3.0'.freeze
3
+ VERSION = '1.4.0'.freeze
4
4
  end
5
5
  end
@@ -5,60 +5,92 @@ require 'support/capybara'
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
 
@@ -20,6 +20,17 @@ ActiveRecord::Schema.define do
20
20
  t.boolean :published
21
21
  end
22
22
 
23
+ create_table(:rgb_colors, force: true) do |t|
24
+ t.string :code
25
+ t.text :description
26
+ end
27
+
28
+ create_table(:internal_tag_names, force: true) do |t|
29
+ t.string :name
30
+ t.text :description
31
+ t.integer :color_id
32
+ end
33
+
23
34
  create_table(:users, force: true) do |t|
24
35
  t.string :name
25
36
  end
@@ -13,6 +13,20 @@ class Post < ActiveRecord::Base
13
13
  scope(:published, -> { where(published: true) })
14
14
  end
15
15
 
16
+ module RGB
17
+ class Color < ActiveRecord::Base
18
+ self.table_name = :rgb_colors
19
+ has_many :tags, class_name: 'Internal::TagName'
20
+ end
21
+ end
22
+
23
+ module Internal
24
+ class TagName < ActiveRecord::Base
25
+ self.table_name = :internal_tag_names
26
+ belongs_to :color, class_name: 'RGB::Color', foreign_key: :color_id
27
+ end
28
+ end
29
+
16
30
  RSpec.configure do |config|
17
31
  config.after do
18
32
  DatabaseCleaner.strategy = :truncation
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activeadmin-searchable_select
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Codevise Solutions Ltd
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-03 00:00:00.000000000 Z
11
+ date: 2021-02-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -375,7 +375,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
375
375
  - !ruby/object:Gem::Version
376
376
  version: '0'
377
377
  requirements: []
378
- rubygems_version: 3.2.3
378
+ rubygems_version: 3.0.8
379
379
  signing_key:
380
380
  specification_version: 4
381
381
  summary: Use searchable selects based on Select2 in Active Admin forms and filters.