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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4cdc05ffd7952e0e2200670bc30d4ea4865bf1b0
4
- data.tar.gz: 164d52ac41d5712a9327689bf3ab94ff00ea1352
3
+ metadata.gz: 1dea784fe1d78c8a7b7d35502636b0de1b64879e
4
+ data.tar.gz: ca5c6e5be03c82625ae7396a126759b456e5d04f
5
5
  SHA512:
6
- metadata.gz: c49a22dc727e96450b680ebca19d8ed9ae6dc9dda3b8584bd2748df1a4ec93ed63b4129c5a41ed393d86e6c859521059015ffad07da03a7c34dac1b90fb393ea
7
- data.tar.gz: 3c1415cd6311ca97d6a0da0acb5809ceaf223f07af099b6d6471ad9925ccfdab34b48d2160bf8c924c4eb12755f946d0c22c0a79681cf8ee7dd0a5058bbec251
6
+ metadata.gz: df7361d081db570f9195f0bd04e079a3ddd82a2083bfafb7fe1c9b2c6c20462b986001d17e551b54707a0bf02c5dbef98a178f6a32348b6650160df9e0b8c818
7
+ data.tar.gz: 1019eeb1f5d5b9b323bed52bb37253a330829ad09093649b86291b070f67a27efd55406dfbd23f889f246638b923e57d86b0bb51bc087a0cdbab30e9c55de450
@@ -1,4 +1,8 @@
1
- ## 2.5.0 2015-11-10
1
+ ## 2.5.2 2015-11-10
2
+
3
+ * #127 - Fix multi-selects - @jjballano
4
+
5
+ ## 2.5.1 2015-11-10
2
6
 
3
7
  * #118 - Fix bad require of countries gem that caused issues if you
4
8
  already had a `Country` class
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- country_select (2.5.0)
4
+ country_select (2.5.1)
5
5
  countries (~> 1.2.0)
6
6
  sort_alphabetical (~> 1.0)
7
7
 
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
@@ -25,7 +25,7 @@ GIT
25
25
  PATH
26
26
  remote: ../
27
27
  specs:
28
- country_select (2.5.0)
28
+ country_select (2.5.1)
29
29
  countries (~> 1.2.0)
30
30
  sort_alphabetical (~> 1.0)
31
31
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- country_select (2.5.0)
4
+ country_select (2.5.1)
5
5
  countries (~> 1.2.0)
6
6
  sort_alphabetical (~> 1.0)
7
7
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- country_select (2.5.0)
4
+ country_select (2.5.1)
5
5
  countries (~> 1.2.0)
6
6
  sort_alphabetical (~> 1.0)
7
7
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- country_select (2.5.0)
4
+ country_select (2.5.1)
5
5
  countries (~> 1.2.0)
6
6
  sort_alphabetical (~> 1.0)
7
7
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- country_select (2.5.0)
4
+ country_select (2.5.1)
5
5
  countries (~> 1.2.0)
6
6
  sort_alphabetical (~> 1.0)
7
7
 
@@ -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
- if priority_countries_options.map(&:second).include?(option_tags_options[:selected])
17
- option_tags_options[:selected] = nil
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
@@ -1,3 +1,3 @@
1
1
  module CountrySelect
2
- VERSION = "2.5.1"
2
+ VERSION = "2.5.2"
3
3
  end
@@ -77,11 +77,23 @@ describe "CountrySelect" do
77
77
  expect(t).to include(tag)
78
78
  end
79
79
 
80
- it "selects only the first matching option" do
81
- tag = options_for_select([["United States", "US"],["Uruguay", "UY"]], "US")
82
- walrus.country_code = 'US'
83
- t = builder.country_select(:country_code, priority_countries: ['LV','US'])
84
- expect(t).to_not include(tag)
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.1
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: 2015-11-10 00:00:00.000000000 Z
11
+ date: 2016-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack