selections 0.1.6 → 0.1.7
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.
- data/CHANGELOG.md +13 -8
- data/lib/selections/form_builder_extensions.rb +2 -2
- data/lib/selections/version.rb +1 -1
- data/spec/selections/selections_tag_spec.rb +46 -13
- metadata +2 -2
data/CHANGELOG.md
CHANGED
@@ -1,20 +1,25 @@
|
|
1
|
-
## 0.
|
1
|
+
## 0.1.7
|
2
2
|
|
3
|
-
*
|
3
|
+
* https://github.com/nigelr/selections/issues/5 - issue with forgetting selected item when page was invalid
|
4
4
|
|
5
|
-
## 0.1.
|
5
|
+
## 0.1.6
|
6
6
|
|
7
|
-
*
|
7
|
+
* Fixed issue with options and html_options order
|
8
|
+
|
9
|
+
## 0.1.3
|
10
|
+
|
11
|
+
* Fixing issue with dependencies on Rubygems
|
8
12
|
|
9
13
|
## 0.1.2
|
10
14
|
|
11
15
|
* Fixing issues with readme
|
12
16
|
|
13
|
-
## 0.1.
|
17
|
+
## 0.1.1
|
14
18
|
|
15
|
-
*
|
19
|
+
* Clean up of specs and readme
|
16
20
|
|
17
|
-
## 0.1
|
21
|
+
## 0.0.1
|
22
|
+
|
23
|
+
* Initial release
|
18
24
|
|
19
|
-
* Fixed issue with options and html_options order
|
20
25
|
|
data/lib/selections/version.rb
CHANGED
@@ -13,7 +13,7 @@ def new_form args = {}
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def common_form args = {}
|
16
|
-
args[:form]
|
16
|
+
args[:form] ||= form
|
17
17
|
args[:field] ||= :priority
|
18
18
|
args[:html_options] ||= {}
|
19
19
|
args[:options] ||= {}
|
@@ -45,13 +45,13 @@ describe SelectionTag do
|
|
45
45
|
before { model_parent }
|
46
46
|
it("should find more explicit route of model parent") { expect(edit_form.system_code).to eq(model_parent) }
|
47
47
|
it "should use priority system_code when model is not ticket" do
|
48
|
-
expect(edit_form(form: ActionView::Helpers::FormBuilder.new(:user, :user, ActionView::Base.new, {}, Proc.new {})
|
48
|
+
expect(edit_form(form: ActionView::Helpers::FormBuilder.new(:user, :user, ActionView::Base.new, {}, Proc.new {})).system_code).to eq(parent)
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
53
|
context "system_code override" do
|
54
|
-
it
|
54
|
+
it 'passes through system code' do
|
55
55
|
hello = Selection.create(name: "hello")
|
56
56
|
parent
|
57
57
|
expect(new_form(options: {system_code: :hello} ).system_code).to eq hello
|
@@ -174,21 +174,54 @@ describe SelectionTag do
|
|
174
174
|
before { all_selections }
|
175
175
|
|
176
176
|
context "when default not set" do
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
177
|
+
context "when new form" do
|
178
|
+
it 'has no value' do
|
179
|
+
expect(new_form.selected_item).to eq("")
|
180
|
+
end
|
181
|
+
it 'priority value is already set (simulating a failed validation)' do
|
182
|
+
expect(new_form(object: Ticket.new(priority_id: selection_3.id)).selected_item).to eq(selection_3.id.to_s)
|
183
|
+
end
|
184
|
+
end
|
185
|
+
context "when edit form" do
|
186
|
+
context "ticket.priority_id set" do
|
187
|
+
before { ticket.update_attribute(:priority_id, selection_3.id) }
|
188
|
+
|
189
|
+
it { expect(edit_form.selected_item).to eq(selection_3.id.to_s) }
|
190
|
+
it 'priority value is changed (simulating a failed validation)' do
|
191
|
+
expect(edit_form(object: ticket.assign_attributes(priority_id: selection_2.id)).selected_item).to eq(selection_2.id.to_s)
|
192
|
+
end
|
193
|
+
end
|
194
|
+
context 'no ticket.priority_id set' do
|
195
|
+
it { expect(edit_form.selected_item).to eq("") }
|
196
|
+
it 'priority value is changed (simulating a failed validation)' do
|
197
|
+
expect(edit_form(object: ticket.assign_attributes(priority_id: selection_2.id)).selected_item).to eq(selection_2.id.to_s)
|
198
|
+
end
|
199
|
+
end
|
181
200
|
end
|
182
|
-
it("when edit form with no ticket.priority_id set") { expect(edit_form.selected_item).to eq("") }
|
183
201
|
end
|
184
202
|
context "when default is set" do
|
185
203
|
before { selection_2.update_attribute(:is_default, true) }
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
204
|
+
|
205
|
+
context 'new form' do
|
206
|
+
it { expect(new_form.selected_item).to eq(selection_2.id.to_s) }
|
207
|
+
it 'priority value is already set (simulating a failed validation)' do
|
208
|
+
expect(new_form(object: Ticket.new(priority_id: selection_3.id)).selected_item).to eq(selection_3.id.to_s)
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
context 'edit form' do
|
213
|
+
it('has no ticket.priority_id set') { expect(edit_form.selected_item).to eq("") }
|
214
|
+
context 'has ticket.priority_id set' do
|
215
|
+
before { ticket.update_attribute(:priority_id, selection_3.id) }
|
216
|
+
|
217
|
+
it 'should not change' do
|
218
|
+
expect(edit_form.selected_item).to eq(selection_3.id.to_s)
|
219
|
+
end
|
220
|
+
it 'priority value is changed (simulating a failed validation)' do
|
221
|
+
expect(edit_form(object: ticket.assign_attributes(priority_id: selection_2.id)).selected_item).to eq(selection_2.id.to_s)
|
222
|
+
end
|
223
|
+
end
|
190
224
|
end
|
191
|
-
it("when edit form with no ticket.priority_id set") { expect(edit_form.selected_item).to eq("") }
|
192
225
|
end
|
193
226
|
end
|
194
227
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: selections
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-03-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|