country_select 6.1.1 → 8.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -92,9 +92,26 @@ describe "CountrySelect" do
92
92
  it "accepts priority countries" do
93
93
  tag = options_for_select(
94
94
  [
95
+ ['Denmark', 'DK'],
95
96
  ['Latvia','LV'],
96
97
  ['United States','US'],
98
+ ['-'*15,'-'*15]
99
+ ],
100
+ selected: 'US',
101
+ disabled: '-'*15
102
+ )
103
+
104
+ walrus.country_code = 'US'
105
+ t = builder.country_select(:country_code, priority_countries: ['LV','US','DK'])
106
+ expect(t).to include(tag)
107
+ end
108
+
109
+ it "priority countries are sorted by name by default" do
110
+ tag = options_for_select(
111
+ [
97
112
  ['Denmark', 'DK'],
113
+ ['Latvia','LV'],
114
+ ['United States','US'],
98
115
  ['-'*15,'-'*15]
99
116
  ],
100
117
  selected: 'US',
@@ -106,6 +123,41 @@ describe "CountrySelect" do
106
123
  expect(t).to include(tag)
107
124
  end
108
125
 
126
+ it "priority countries with `sort_provided: false` preserves the provided order" do
127
+ tag = options_for_select(
128
+ [
129
+ ['Latvia','LV'],
130
+ ['United States','US'],
131
+ ['Denmark', 'DK'],
132
+ ['-'*15,'-'*15]
133
+ ],
134
+ selected: 'US',
135
+ disabled: '-'*15
136
+ )
137
+
138
+ walrus.country_code = 'US'
139
+ t = builder.country_select(:country_code, priority_countries: ['LV','US','DK'], sort_provided: false)
140
+ expect(t).to include(tag)
141
+ end
142
+
143
+ it "priority countries with `sort_provided: false` still sorts the non-priority countries by name" do
144
+ tag = options_for_select(
145
+ [
146
+ ['Latvia','LV'],
147
+ ['United States','US'],
148
+ ['Denmark', 'DK'],
149
+ ['-'*15,'-'*15],
150
+ ['Afghanistan','AF']
151
+ ],
152
+ selected: 'AF',
153
+ disabled: '-'*15
154
+ )
155
+
156
+ walrus.country_code = 'AF'
157
+ t = builder.country_select(:country_code, priority_countries: ['LV','US','DK'], sort_provided: false)
158
+ expect(t).to include(tag)
159
+ end
160
+
109
161
  describe "when selected options is not an array" do
110
162
  it "selects only the first matching option" do
111
163
  tag = options_for_select([["United States", "US"],["Uruguay", "UY"]], "US")
@@ -139,6 +191,18 @@ describe "CountrySelect" do
139
191
  expect(t).to_not include(tag)
140
192
  end
141
193
 
194
+ it "countries provided in `only` are sorted by name by default" do
195
+ t = builder.country_select(:country_code, only: ['PT','DE','AR'])
196
+ order = t.scan(/value="(\w{2})"/).map { |o| o[0] }
197
+ expect(order).to eq(['AR', 'DE', 'PT'])
198
+ end
199
+
200
+ it "countries provided in `only` with `sort_provided` to false keeps the order of the provided countries" do
201
+ t = builder.country_select(:country_code, only: ['PT','DE','AR'], sort_provided: false)
202
+ order = t.scan(/value="(\w{2})"/).map { |o| o[0] }
203
+ expect(order).to eq(['PT','DE','AR'])
204
+ end
205
+
142
206
  context "when there is a default 'except' configured" do
143
207
  around do |example|
144
208
  old_value = ::CountrySelect::DEFAULTS[:except]
@@ -160,9 +224,9 @@ describe "CountrySelect" do
160
224
  it "accepts priority countries" do
161
225
  tag = options_for_select(
162
226
  [
227
+ ['Denmark', 'DK'],
163
228
  ['Latvia','LV'],
164
229
  ['United States','US'],
165
- ['Denmark', 'DK'],
166
230
  ['-'*15,'-'*15]
167
231
  ],
168
232
  selected: 'US',
@@ -235,23 +299,6 @@ describe "CountrySelect" do
235
299
  expect(order).to eq(['AF', 'AX', 'AL', 'ZW'])
236
300
  end
237
301
 
238
- context "without sort_alphabetical" do
239
- before do
240
- Enumerable.send(:alias_method, :_sort_alphabetical, :sort_alphabetical)
241
- Enumerable.send(:remove_method, :sort_alphabetical)
242
- end
243
-
244
- after do
245
- Enumerable.send(:alias_method, :sort_alphabetical, :_sort_alphabetical)
246
- end
247
-
248
- it 'falls back to regular sort' do
249
- tag = builder.country_select(:country_code, only: ['AX', 'AL', 'AF', 'ZW'])
250
- order = tag.scan(/value="(\w{2})"/).map { |o| o[0] }
251
- expect(order).to eq(['AF', 'AL', 'ZW', 'AX'])
252
- end
253
- end
254
-
255
302
  describe "custom formats" do
256
303
  it "accepts a custom formatter" do
257
304
  ::CountrySelect::FORMATS[:with_alpha2] = lambda do |country|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: country_select
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.1.1
4
+ version: 8.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Penner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-20 00:00:00.000000000 Z
11
+ date: 2023-01-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -72,28 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '4.2'
75
+ version: '5.0'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '4.2'
83
- - !ruby/object:Gem::Dependency
84
- name: sort_alphabetical
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: '1.1'
90
- type: :runtime
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: '1.1'
82
+ version: '5.0'
97
83
  description: Provides a simple helper to get an HTML select list of countries. The
98
84
  list of countries comes from the ISO 3166 standard. While it is a relatively neutral
99
85
  source of country names, it will still offend some users.
@@ -104,6 +90,7 @@ extensions: []
104
90
  extra_rdoc_files: []
105
91
  files:
106
92
  - ".github/workflows/build.yml"
93
+ - ".github/workflows/codeql-analysis.yml"
107
94
  - ".gitignore"
108
95
  - ".rspec"
109
96
  - CHANGELOG.md
@@ -122,21 +109,21 @@ files:
122
109
  - gemfiles/actionpack-6.1.gemfile.lock
123
110
  - gemfiles/actionpack-7.0.gemfile
124
111
  - gemfiles/actionpack-7.0.gemfile.lock
125
- - gemfiles/actionpack-head.gemfile
126
- - gemfiles/actionpack-head.gemfile.lock
127
112
  - lib/country_select.rb
128
113
  - lib/country_select/country_select_helper.rb
129
114
  - lib/country_select/defaults.rb
130
115
  - lib/country_select/formats.rb
131
116
  - lib/country_select/tag_helper.rb
132
117
  - lib/country_select/version.rb
133
- - lib/country_select_without_sort_alphabetical.rb
134
118
  - spec/country_select_spec.rb
135
119
  - spec/spec_helper.rb
136
120
  homepage: https://github.com/countries/country_select
137
121
  licenses:
138
122
  - MIT
139
- metadata: {}
123
+ metadata:
124
+ bug_tracker_uri: http://github.com/countries/country_select/issues
125
+ changelog_uri: https://github.com/countries/country_select/blob/master/CHANGELOG.md
126
+ source_code_uri: https://github.com/countries/country_select
140
127
  post_install_message:
141
128
  rdoc_options: []
142
129
  require_paths:
@@ -145,14 +132,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
145
132
  requirements:
146
133
  - - ">="
147
134
  - !ruby/object:Gem::Version
148
- version: '2.5'
135
+ version: '2.7'
149
136
  required_rubygems_version: !ruby/object:Gem::Requirement
150
137
  requirements:
151
138
  - - ">="
152
139
  - !ruby/object:Gem::Version
153
140
  version: '0'
154
141
  requirements: []
155
- rubygems_version: 3.3.3
142
+ rubygems_version: 3.4.2
156
143
  signing_key:
157
144
  specification_version: 4
158
145
  summary: Country Select Plugin
@@ -1,9 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gemspec :path => "../"
4
-
5
- git "https://github.com/rails/rails.git" do
6
- gem "actionpack"
7
- gem "actionview"
8
- gem "activesupport"
9
- end
@@ -1,109 +0,0 @@
1
- GIT
2
- remote: https://github.com/rails/rails.git
3
- revision: 10ef5321c1e0f783b58f26d238cd61145bc3cb96
4
- specs:
5
- actionpack (7.1.0.alpha)
6
- actionview (= 7.1.0.alpha)
7
- activesupport (= 7.1.0.alpha)
8
- rack (~> 2.0, >= 2.2.0)
9
- rack-test (>= 0.6.3)
10
- rails-dom-testing (~> 2.0)
11
- rails-html-sanitizer (~> 1.0, >= 1.2.0)
12
- actionview (7.1.0.alpha)
13
- activesupport (= 7.1.0.alpha)
14
- builder (~> 3.1)
15
- erubi (~> 1.4)
16
- rails-dom-testing (~> 2.0)
17
- rails-html-sanitizer (~> 1.1, >= 1.2.0)
18
- activesupport (7.1.0.alpha)
19
- concurrent-ruby (~> 1.0, >= 1.0.2)
20
- i18n (>= 1.6, < 2)
21
- minitest (>= 5.1)
22
- tzinfo (~> 2.0)
23
-
24
- PATH
25
- remote: ..
26
- specs:
27
- country_select (6.1.1)
28
- countries (~> 4.2)
29
- sort_alphabetical (~> 1.1)
30
-
31
- GEM
32
- remote: https://rubygems.org/
33
- specs:
34
- builder (3.2.4)
35
- coderay (1.1.3)
36
- concurrent-ruby (1.1.9)
37
- countries (4.2.1)
38
- i18n_data (~> 0.15.0)
39
- sixarm_ruby_unaccent (~> 1.1)
40
- crass (1.0.6)
41
- diff-lcs (1.5.0)
42
- erubi (1.10.0)
43
- i18n (1.8.11)
44
- concurrent-ruby (~> 1.0)
45
- i18n_data (0.15.0)
46
- simple_po_parser (~> 1.1)
47
- loofah (2.13.0)
48
- crass (~> 1.0.2)
49
- nokogiri (>= 1.5.9)
50
- method_source (1.0.0)
51
- mini_portile2 (2.7.1)
52
- minitest (5.15.0)
53
- nokogiri (1.13.1)
54
- mini_portile2 (~> 2.7.0)
55
- racc (~> 1.4)
56
- nokogiri (1.13.1-arm64-darwin)
57
- racc (~> 1.4)
58
- nokogiri (1.13.1-x86_64-linux)
59
- racc (~> 1.4)
60
- pry (0.14.1)
61
- coderay (~> 1.1)
62
- method_source (~> 1.0)
63
- racc (1.6.0)
64
- rack (2.2.3)
65
- rack-test (1.1.0)
66
- rack (>= 1.0, < 3)
67
- rails-dom-testing (2.0.3)
68
- activesupport (>= 4.2.0)
69
- nokogiri (>= 1.6)
70
- rails-html-sanitizer (1.4.2)
71
- loofah (~> 2.3)
72
- rake (13.0.6)
73
- rspec (3.10.0)
74
- rspec-core (~> 3.10.0)
75
- rspec-expectations (~> 3.10.0)
76
- rspec-mocks (~> 3.10.0)
77
- rspec-core (3.10.1)
78
- rspec-support (~> 3.10.0)
79
- rspec-expectations (3.10.2)
80
- diff-lcs (>= 1.2.0, < 2.0)
81
- rspec-support (~> 3.10.0)
82
- rspec-mocks (3.10.2)
83
- diff-lcs (>= 1.2.0, < 2.0)
84
- rspec-support (~> 3.10.0)
85
- rspec-support (3.10.3)
86
- simple_po_parser (1.1.5)
87
- sixarm_ruby_unaccent (1.2.0)
88
- sort_alphabetical (1.1.0)
89
- unicode_utils (>= 1.2.2)
90
- tzinfo (2.0.4)
91
- concurrent-ruby (~> 1.0)
92
- unicode_utils (1.4.0)
93
-
94
- PLATFORMS
95
- arm64-darwin-21
96
- ruby
97
- x86_64-linux
98
-
99
- DEPENDENCIES
100
- actionpack!
101
- actionview!
102
- activesupport!
103
- country_select!
104
- pry (~> 0)
105
- rake (~> 13)
106
- rspec (~> 3)
107
-
108
- BUNDLED WITH
109
- 2.3.3
@@ -1,9 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'countries'
4
-
5
- require 'country_select/version'
6
- require 'country_select/defaults'
7
- require 'country_select/formats'
8
- require 'country_select/tag_helper'
9
- require 'country_select/country_select_helper'