country_select 2.5.1 → 2.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -1
- data/Gemfile.lock +1 -1
- data/README.md +6 -0
- data/gemfiles/actionpack.edge.gemfile.lock +1 -1
- data/gemfiles/actionpack3.2.gemfile.lock +1 -1
- data/gemfiles/actionpack4.0.gemfile.lock +1 -1
- data/gemfiles/actionpack4.1.gemfile.lock +1 -1
- data/gemfiles/actionpack4.2.gemfile.lock +1 -1
- data/lib/country_select/tag_helper.rb +2 -3
- data/lib/country_select/version.rb +1 -1
- data/spec/country_select_spec.rb +17 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1dea784fe1d78c8a7b7d35502636b0de1b64879e
|
4
|
+
data.tar.gz: ca5c6e5be03c82625ae7396a126759b456e5d04f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df7361d081db570f9195f0bd04e079a3ddd82a2083bfafb7fe1c9b2c6c20462b986001d17e551b54707a0bf02c5dbef98a178f6a32348b6650160df9e0b8c818
|
7
|
+
data.tar.gz: 1019eeb1f5d5b9b323bed52bb37253a330829ad09093649b86291b070f67a27efd55406dfbd23f889f246638b923e57d86b0bb51bc087a0cdbab30e9c55de450
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -61,6 +61,12 @@ Pre-selecting a particular country:
|
|
61
61
|
country_select("user", "country", selected: "GB")
|
62
62
|
```
|
63
63
|
|
64
|
+
Using existing `select` options:
|
65
|
+
```ruby
|
66
|
+
country_select("user", "country", include_blank: true)
|
67
|
+
country_select("user", "country", { include_blank: 'Select a country' }, { class: 'country-select-box' })
|
68
|
+
```
|
69
|
+
|
64
70
|
Supplying additional html options:
|
65
71
|
|
66
72
|
```ruby
|
@@ -13,9 +13,8 @@ module CountrySelect
|
|
13
13
|
option_tags = options_for_select(priority_countries_options, option_tags_options)
|
14
14
|
option_tags += html_safe_newline + options_for_select([priority_countries_divider], disabled: priority_countries_divider)
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
end
|
16
|
+
option_tags_options[:selected] = [option_tags_options[:selected]] unless option_tags_options[:selected].kind_of?(Array)
|
17
|
+
option_tags_options[:selected].delete_if{|selected| priority_countries_options.map(&:second).include?(selected)}
|
19
18
|
|
20
19
|
option_tags += html_safe_newline + options_for_select(country_options, option_tags_options)
|
21
20
|
else
|
data/spec/country_select_spec.rb
CHANGED
@@ -77,11 +77,23 @@ describe "CountrySelect" do
|
|
77
77
|
expect(t).to include(tag)
|
78
78
|
end
|
79
79
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
80
|
+
describe "when selected options is not an array" do
|
81
|
+
it "selects only the first matching option" do
|
82
|
+
tag = options_for_select([["United States", "US"],["Uruguay", "UY"]], "US")
|
83
|
+
walrus.country_code = 'US'
|
84
|
+
t = builder.country_select(:country_code, priority_countries: ['LV','US'])
|
85
|
+
expect(t).to_not include(tag)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
describe "when selected options is an array" do
|
90
|
+
it "selects all options but only once" do
|
91
|
+
tag = options_for_select([["United States", "US"],["Uruguay", "UY"],["Spain", "ES"]], "US")
|
92
|
+
walrus.country_code = 'US'
|
93
|
+
t = builder.country_select(:country_code, {priority_countries: ['LV','US','ES'], selected: ['UY', 'US']}, multiple: true)
|
94
|
+
expect(t.scan(options_for_select([["United States", "US"]], "US")).length).to be(1)
|
95
|
+
expect(t.scan(options_for_select([["Uruguay", "UY"]], "UY")).length).to be(1)
|
96
|
+
end
|
85
97
|
end
|
86
98
|
|
87
99
|
it "displays only the chosen countries" do
|
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: 2.5.
|
4
|
+
version: 2.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefan Penner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-03-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|