selections 0.0.1 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. data/.gitignore +18 -0
  2. data/CHANGELOG.md +3 -0
  3. data/Gemfile +4 -0
  4. data/{MIT-LICENSE → LICENSE.txt} +4 -2
  5. data/README.md +237 -0
  6. data/Rakefile +3 -29
  7. data/lib/selections.rb +22 -6
  8. data/lib/selections/belongs_to_selection.rb +20 -0
  9. data/lib/selections/form_builder_extensions.rb +86 -0
  10. data/lib/selections/selectable.rb +125 -0
  11. data/lib/selections/version.rb +1 -1
  12. data/selections.gemspec +38 -0
  13. data/spec/selections/selectable_spec.rb +220 -0
  14. data/spec/selections/selections_tag_spec.rb +203 -0
  15. data/spec/spec_helper.rb +30 -21
  16. metadata +99 -177
  17. data/README.rdoc +0 -3
  18. data/app/assets/javascripts/selections/application.js +0 -9
  19. data/app/assets/javascripts/selections/selections.js +0 -2
  20. data/app/assets/stylesheets/scaffold.css +0 -56
  21. data/app/assets/stylesheets/selections/application.css +0 -7
  22. data/app/assets/stylesheets/selections/selections.css +0 -4
  23. data/app/controllers/selections/application_controller.rb +0 -4
  24. data/app/controllers/selections/selections_controller.rb +0 -45
  25. data/app/helpers/selections/application_helper.rb +0 -4
  26. data/app/helpers/selections/selectors_helper.rb +0 -4
  27. data/app/models/selections/selection.rb +0 -83
  28. data/app/views/layouts/selections/application.html.erb +0 -1
  29. data/app/views/selections/selections/_form.html.erb +0 -41
  30. data/app/views/selections/selections/edit.html.erb +0 -6
  31. data/app/views/selections/selections/index.html.erb +0 -33
  32. data/app/views/selections/selections/new.html.erb +0 -5
  33. data/app/views/selections/selections/show.html.erb +0 -35
  34. data/config/initializers/selections.rb +0 -1
  35. data/config/routes.rb +0 -5
  36. data/db/migrate/20120114024459_create_selections_selections.rb +0 -15
  37. data/lib/selections/engine.rb +0 -5
  38. data/lib/selections/selection_select.rb +0 -24
  39. data/lib/tasks/selections_tasks.rake +0 -4
  40. data/spec/controllers/companies_controller_spec.rb +0 -10
  41. data/spec/controllers/selections/selections_controller_spec.rb +0 -165
  42. data/spec/dummy/Rakefile +0 -7
  43. data/spec/dummy/app/assets/javascripts/application.js +0 -9
  44. data/spec/dummy/app/assets/javascripts/companies.js +0 -2
  45. data/spec/dummy/app/assets/stylesheets/application.css +0 -7
  46. data/spec/dummy/app/assets/stylesheets/companies.css +0 -4
  47. data/spec/dummy/app/assets/stylesheets/scaffold.css +0 -56
  48. data/spec/dummy/app/controllers/application_controller.rb +0 -2
  49. data/spec/dummy/app/controllers/companies_controller.rb +0 -83
  50. data/spec/dummy/app/helpers/application_helper.rb +0 -2
  51. data/spec/dummy/app/helpers/companies_helper.rb +0 -2
  52. data/spec/dummy/app/models/company.rb +0 -7
  53. data/spec/dummy/app/views/companies/_form.html.erb +0 -3
  54. data/spec/dummy/app/views/companies/edit.html.erb +0 -4
  55. data/spec/dummy/app/views/companies/index.html.erb +0 -27
  56. data/spec/dummy/app/views/companies/new.html.erb +0 -5
  57. data/spec/dummy/app/views/companies/show.html.erb +0 -20
  58. data/spec/dummy/app/views/layouts/application.html.erb +0 -11
  59. data/spec/dummy/config.ru +0 -4
  60. data/spec/dummy/config/application.rb +0 -45
  61. data/spec/dummy/config/boot.rb +0 -10
  62. data/spec/dummy/config/database.yml +0 -25
  63. data/spec/dummy/config/environment.rb +0 -5
  64. data/spec/dummy/config/environments/development.rb +0 -30
  65. data/spec/dummy/config/environments/production.rb +0 -60
  66. data/spec/dummy/config/environments/test.rb +0 -42
  67. data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
  68. data/spec/dummy/config/initializers/inflections.rb +0 -10
  69. data/spec/dummy/config/initializers/mime_types.rb +0 -5
  70. data/spec/dummy/config/initializers/secret_token.rb +0 -7
  71. data/spec/dummy/config/initializers/session_store.rb +0 -8
  72. data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
  73. data/spec/dummy/config/locales/en.yml +0 -5
  74. data/spec/dummy/config/routes.rb +0 -6
  75. data/spec/dummy/db/development.sqlite3 +0 -0
  76. data/spec/dummy/db/migrate/20120114125226_create_selections_selections.rb +0 -15
  77. data/spec/dummy/db/migrate/20120115055119_create_companies.rb +0 -12
  78. data/spec/dummy/db/schema.rb +0 -38
  79. data/spec/dummy/db/test.sqlite3 +0 -0
  80. data/spec/dummy/log/development.log +0 -94
  81. data/spec/dummy/log/test.log +0 -26360
  82. data/spec/dummy/public/404.html +0 -26
  83. data/spec/dummy/public/422.html +0 -26
  84. data/spec/dummy/public/500.html +0 -26
  85. data/spec/dummy/public/favicon.ico +0 -0
  86. data/spec/dummy/script/rails +0 -6
  87. data/spec/helpers/selections/selections_helper_spec.rb +0 -15
  88. data/spec/models/company_spec.rb +0 -7
  89. data/spec/models/selections/selection_spec.rb +0 -219
  90. data/spec/routing/selections/selections_routing_spec.rb +0 -35
  91. data/spec/support/controller_route_fix.rb +0 -33
  92. data/spec/support/factories/company_factory.rb +0 -5
  93. data/spec/support/factories/selection_factory.rb +0 -5
  94. data/spec/views/companies/edit.html.erb_spec.rb +0 -76
  95. data/spec/views/companies/new.html.erb_spec.rb +0 -78
  96. data/spec/views/selections/selections/edit.html.erb_spec.rb +0 -28
  97. data/spec/views/selections/selections/index.html.erb_spec.rb +0 -40
  98. data/spec/views/selections/selections/new.html.erb_spec.rb +0 -28
  99. data/spec/views/selections/selections/show.html.erb_spec.rb +0 -30
@@ -1,26 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>The page you were looking for doesn't exist (404)</title>
5
- <style type="text/css">
6
- body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
- div.dialog {
8
- width: 25em;
9
- padding: 0 4em;
10
- margin: 4em auto 0 auto;
11
- border: 1px solid #ccc;
12
- border-right-color: #999;
13
- border-bottom-color: #999;
14
- }
15
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
- </style>
17
- </head>
18
-
19
- <body>
20
- <!-- This file lives in public/404.html -->
21
- <div class="dialog">
22
- <h1>The page you were looking for doesn't exist.</h1>
23
- <p>You may have mistyped the address or the page may have moved.</p>
24
- </div>
25
- </body>
26
- </html>
@@ -1,26 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>The change you wanted was rejected (422)</title>
5
- <style type="text/css">
6
- body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
- div.dialog {
8
- width: 25em;
9
- padding: 0 4em;
10
- margin: 4em auto 0 auto;
11
- border: 1px solid #ccc;
12
- border-right-color: #999;
13
- border-bottom-color: #999;
14
- }
15
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
- </style>
17
- </head>
18
-
19
- <body>
20
- <!-- This file lives in public/422.html -->
21
- <div class="dialog">
22
- <h1>The change you wanted was rejected.</h1>
23
- <p>Maybe you tried to change something you didn't have access to.</p>
24
- </div>
25
- </body>
26
- </html>
@@ -1,26 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>We're sorry, but something went wrong (500)</title>
5
- <style type="text/css">
6
- body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
- div.dialog {
8
- width: 25em;
9
- padding: 0 4em;
10
- margin: 4em auto 0 auto;
11
- border: 1px solid #ccc;
12
- border-right-color: #999;
13
- border-bottom-color: #999;
14
- }
15
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
- </style>
17
- </head>
18
-
19
- <body>
20
- <!-- This file lives in public/500.html -->
21
- <div class="dialog">
22
- <h1>We're sorry, but something went wrong.</h1>
23
- <p>We've been notified about this issue and we'll take a look at it shortly.</p>
24
- </div>
25
- </body>
26
- </html>
File without changes
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
-
4
- APP_PATH = File.expand_path('../../config/application', __FILE__)
5
- require File.expand_path('../../config/boot', __FILE__)
6
- require 'rails/commands'
@@ -1,15 +0,0 @@
1
- #require 'spec_helper'
2
- #
3
- ## Specs in this file have access to a helper object that includes
4
- ## the SelectionsHelper. For example:
5
- ##
6
- ## describe SelectionsHelper do
7
- ## describe "string concat" do
8
- ## it "concats two strings with spaces" do
9
- ## helper.concat_strings("this","that").should == "this that"
10
- ## end
11
- ## end
12
- ## end
13
- #describe SelectionsHelper do
14
- # pending "add some examples to (or delete) #{__FILE__}"
15
- #end
@@ -1,7 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Company do
4
- it "should be valid" do
5
- Factory(:company).should be_valid
6
- end
7
- end
@@ -1,219 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Selections
4
- describe Selection do
5
- it("should be valid") { Factory(:selection).should be_valid }
6
-
7
- it("should require valid name") { Factory.build(:selection, :name => "").should_not be_valid }
8
-
9
- context "duplicates" do
10
- let(:parent_1) { Factory(:selection) }
11
- let(:parent_2) { Factory(:selection) }
12
- before { Factory(:selection, :name => "duplicate", :parent_id => parent_1.id) }
13
-
14
- it "should allow duplicates under different parents" do
15
- Factory.build(:selection, :name => "duplicate", :parent_id => parent_2.id).should be_valid
16
- end
17
- it "should not allow duplicates same parents" do
18
- Factory.build(:selection, :name => "duplicate", :parent_id => parent_1.id).should_not be_valid
19
- end
20
- end
21
- describe ".system_code" do
22
- context "autogenerating" do
23
- context "create" do
24
- context "parent" do
25
- it("should not generate system_code when one set") do
26
- Factory(:selection, :name => "Priorities", :system_code => "something_else").system_code.should == "something_else"
27
- end
28
- it("generate singular system_code") { Factory(:selection, :name => "Priorities").system_code.should == "priority" }
29
- it("generate system_code when name has spaces") { Factory(:selection, :name => "telephone prefixes").system_code.should == "telephone_prefix" }
30
- it("generate system_code when camelcased") { Factory(:selection, :name => "TelephonePrefixes").system_code.should == "telephone_prefix" }
31
-
32
- end
33
- context "children" do
34
- it "should contain auto parent and child code" do
35
- parent = Factory(:selection)
36
- child_1 = Factory(:selection, :parent => parent)
37
- child_1.system_code.should == "#{parent.name}_#{child_1.name}"
38
- end
39
- it "should be child system_code when defined" do
40
- parent = Factory(:selection, :system_code => "hello")
41
- child_1 = Factory(:selection, :parent => parent, :system_code => "world")
42
- child_1.system_code.should == "world"
43
- end
44
- it "should contain parent and child code when defined" do
45
- parent = Factory(:selection, :system_code => "hello")
46
- child_1 = Factory(:selection, :parent => parent, :name => "world")
47
- child_1.system_code.should == "hello_world"
48
- end
49
- end
50
- end
51
- context "update" do
52
- before { @parent = Factory(:selection) }
53
- it "should not autogenerate system_code" do
54
- @parent.update_attribute(:system_code, nil)
55
- @parent.update_attributes(:name => "hello")
56
- @parent.system_code.should be_nil
57
- end
58
- it "should not allow update of system_code" do
59
- @parent.system_code = "different"
60
- @parent.should have(1).error_on(:system_code)
61
- @parent.errors[:system_code].should include("cannot be changed")
62
- end
63
- end
64
- end
65
- context "uniqueness of system codes" do
66
- before { @selection_1 = Factory(:selection) }
67
- it("should not allow same system_codes") { FactoryGirl.build(:selection, :system_code => @selection_1.system_code).should_not be_valid }
68
- it("should allow same system_codes if one archived") do
69
- @selection_1.update_attributes(:archived => true)
70
- FactoryGirl.build(:selection, :system_code => @selection_1.system_code).should be_valid
71
- end
72
- end
73
- context "valid system_code characters" do
74
- it("should not allow !") { FactoryGirl.build(:selection, :system_code => "hello!world").should_not be_valid }
75
- it("should not allow $") { FactoryGirl.build(:selection, :system_code => "hello$world").should_not be_valid }
76
- it("should not allow starting with _") { FactoryGirl.build(:selection, :system_code => "_hello").should_not be_valid }
77
- it("should allow containing _") { FactoryGirl.build(:selection, :system_code => "hello_world").should be_valid }
78
- it "should not have spaces" do
79
- FactoryGirl.build(:selection, :system_code => "hello world").should_not be_valid
80
- end
81
- end
82
- end
83
-
84
- context "common data" do
85
- before do
86
- @parent_1 = Factory(:selection)
87
- @child_1 = Factory(:selection, :parent => @parent_1)
88
- @child_2 = Factory(:selection, :parent => @parent_1, :is_default => true)
89
- @child_3 = Factory(:selection, :parent => @parent_1)
90
- @child_4 = Factory(:selection, :parent => @parent_1)
91
- end
92
-
93
-
94
- describe ".to_s" do
95
- it "should return name when only relationship is defined" do
96
- company = Factory(:company, :state_id => @child_4.id)
97
- company.state.to_s.should == @child_4.name
98
- end
99
- end
100
-
101
- describe ".position" do
102
- it("should save positive position") { Factory(:selection, :position => 10).position.should == 10 }
103
- it("should save negative position") { Factory(:selection, :position => -20).position.should == -20 }
104
- it("should save 0 position") { Factory(:selection, :position => 0).position.should == 0 }
105
- it("should save string as 0 position") { Factory(:selection, :position => "hello").position.should == 0 }
106
- it("should return hidden_position as empty string") { Factory(:selection, :position => Selections::Selection::HIDDEN_POSITION).position.should be_nil }
107
- it("should save nil and return nil") { Factory(:selection, :position => nil).position.should be_nil }
108
- it("should save nil as hidden_position value") { Factory(:selection, :position => nil).position_value.should == Selections::Selection::HIDDEN_POSITION }
109
- end
110
-
111
- describe "default_order" do
112
- it "should return alpha order" do
113
- @child_3.update_attribute(:name, "abc")
114
- @parent_1.reload.children.should == [@child_3, @child_1, @child_2, @child_4]
115
- end
116
- it "should return alpha and numbers first if set" do
117
- @child_3.update_attributes!(:position => 10)
118
- @child_2.update_attributes!(:position => 20)
119
- @parent_1.reload.children.should == [@child_3, @child_2, @child_1, @child_4]
120
- end
121
- end
122
- describe ".filter_archived_except_selected" do
123
- it("should return all children") { @parent_1.children.filter_archived_except_selected(@child_3).should =~ @parent_1.children }
124
- context "one archived" do
125
- before { @child_3.update_attribute(:archived, true) }
126
- it("should return all children except archived") { @parent_1.children.filter_archived_except_selected(@child_1).should =~ @parent_1.children - [@child_3] }
127
- it("should return all children including archived if its selected") { @parent_1.children.filter_archived_except_selected(@child_3).should =~ @parent_1.children }
128
- it "should return all children including archived if its selected except other archived" do
129
- @child_1.update_attribute(:archived, true)
130
- @parent_1.children.filter_archived_except_selected(@child_3).should =~ @parent_1.children - [@child_1]
131
- end
132
- end
133
- end
134
- describe ".siblings_with_default_set" do
135
- it("should return item set to default") { @child_1.siblings_with_default_set.should == @child_2 }
136
- it("should not return itself") { @child_2.siblings_with_default_set.should be_nil }
137
- it "should return nothing if no default" do
138
- @child_2.update_attribute(:is_default, false)
139
- @child_1.siblings_with_default_set.should be_nil
140
- end
141
- end
142
-
143
- describe ".is_default" do
144
- context "setting default" do
145
- before { @child_1.update_attributes!(:is_default=>true) }
146
-
147
- it("should set default") { @child_1.is_default.should be_true }
148
- it("should remove default if any set within scope") do
149
- @child_1.update_attributes!(:is_default=>true)
150
- @child_2.reload.is_default.should be_false
151
- end
152
- end
153
- it "default should be set when adding new item with default on" do
154
- Factory(:selection, :parent => @parent_1, :is_default => true).is_default.should be_true
155
- end
156
- it "when adding new item with default set, should remove other default" do
157
- Factory(:selection, :parent => @parent_1, :is_default => true)
158
- @child_2.reload.is_default.should be_false
159
- end
160
- it "should not remove default item in another scope" do
161
- other_parent = Factory(:selection)
162
- Factory(:selection, :parent => other_parent)
163
- other_child_2 = Factory(:selection, :parent => other_parent, :is_default => true)
164
- @child_1.update_attributes!(:is_default => true)
165
- other_child_2.is_default.should be_true
166
- end
167
-
168
- it "should unset default and not set any other within scope" do
169
- @child_2.update_attributes!(:is_default => false)
170
- @parent_1.children.each do |child|
171
- child.is_default.should be_false
172
- end
173
- end
174
- end
175
- end
176
-
177
- describe ".archived" do
178
- it("should not be archived") { Factory(:selection).archived.should be_false }
179
- it("should be archived") { Factory(:selection, :archived => true).archived.should be_true }
180
- it "should not change archived_at" do
181
- original_time = Time.now - 2.days
182
- selection = Factory(:selection, :archived_at => original_time)
183
- selection.update_attributes(:archived => true)
184
- selection.archived_at.should == original_time
185
- end
186
- it "should unset default if archived" do
187
- default_selections
188
- @child_2.update_attributes(:archived => true)
189
- @child_2.reload.is_default.should be_false
190
- end
191
- end
192
-
193
- context "system_code finds" do
194
- describe "#method_missing" do
195
- before do
196
- @parent_1 = Factory(:selection, :system_code => "parent_1")
197
- @parent_2 = Factory(:selection, :system_code => "parent_2")
198
- @parent_3 = Factory(:selection, :system_code => "parent_3")
199
- end
200
-
201
- it("should return a item with system_code of parent_1") { Selection.parent_1.should == @parent_1 }
202
- it("should return a item with system_code of parent_2") { Selections::Selection.parent_2.should == @parent_2 }
203
- it("should cause an exception if does not exist") { lambda { Selections::Selection.parent_10 }.should raise_exception }
204
- it("should still do normal method missing finds") { Selections::Selection.find_by_system_code(@parent_1.system_code).should == @parent_1 }
205
- it("should still support inbuilt methods") { Selections::Selection.where(:system_code => @parent_1.system_code).first.should == @parent_1 }
206
-
207
- context "pluralized returns children" do
208
- before { @parent_1.children << [Factory(:selection), Factory(:selection)] }
209
-
210
- it("should return children") { Selections::Selection.parent_1s.should == @parent_1.children }
211
- it "'es' pluralization should return children" do
212
- @parent_1.update_attribute(:system_code, "status")
213
- Selections::Selection.statuses.should == @parent_1.children
214
- end
215
- end
216
- end
217
- end
218
- end
219
- end
@@ -1,35 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Selections::SelectionsController do
4
- describe "routing" do
5
-
6
- it "routes to #index" do
7
- get("/selections").should route_to("selections#index")
8
- end
9
-
10
- it "routes to #new" do
11
- get("/selections/new").should route_to("selections#new")
12
- end
13
-
14
- it "routes to #show" do
15
- get("/selections/1").should route_to("selections#show", :id => "1")
16
- end
17
-
18
- it "routes to #edit" do
19
- get("/selections/1/edit").should route_to("selections#edit", :id => "1")
20
- end
21
-
22
- it "routes to #create" do
23
- post("/selections").should route_to("selections#create")
24
- end
25
-
26
- it "routes to #update" do
27
- put("/selections/1").should route_to("selections#update", :id => "1")
28
- end
29
-
30
- it "routes to #destroy" do
31
- delete("/selections/1").should route_to("selections#destroy", :id => "1")
32
- end
33
-
34
- end
35
- end
@@ -1,33 +0,0 @@
1
- module Spree
2
- module ControllerRouteFix
3
- def get(action, parameters = nil, session = nil, flash = nil)
4
- process_spree_action(action, parameters, session, flash, "GET")
5
- end
6
-
7
- # Executes a request simulating POST HTTP method and set/volley the response
8
- def post(action, parameters = nil, session = nil, flash = nil)
9
- process_spree_action(action, parameters, session, flash, "POST")
10
- end
11
-
12
- # Executes a request simulating PUT HTTP method and set/volley the response
13
- def put(action, parameters = nil, session = nil, flash = nil)
14
- process_spree_action(action, parameters, session, flash, "PUT")
15
- end
16
-
17
- # Executes a request simulating DELETE HTTP method and set/volley the response
18
- def delete(action, parameters = nil, session = nil, flash = nil)
19
- process_spree_action(action, parameters, session, flash, "DELETE")
20
- end
21
-
22
- private
23
-
24
- def process_spree_action(action, parameters = nil, session = nil, flash = nil, method = "GET")
25
- parameters ||= {}
26
- process(action, parameters.merge!(:use_route => :selections), session, flash, method)
27
- end
28
- end
29
- end
30
-
31
- RSpec.configure do |c|
32
- c.include Spree::ControllerRouteFix, :type => :controller
33
- end
@@ -1,5 +0,0 @@
1
- FactoryGirl.define do
2
- factory :company do
3
- sequence(:name) {|n| "selection_#{n}"}
4
- end
5
- end
@@ -1,5 +0,0 @@
1
- FactoryGirl.define do
2
- factory :selection, :class => Selections::Selection do
3
- sequence(:name) {|n| "selection_#{n}"}
4
- end
5
- end
@@ -1,76 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "companies/edit" do
4
- context "default selection list" do
5
- before do
6
- @parent_10 = Factory(:selection, :system_code => "state")
7
- @child_11 = Factory(:selection, :parent => @parent_10)
8
- @child_12 = Factory(:selection, :parent => @parent_10, :is_default => true)
9
- @child_13 = Factory(:selection, :parent => @parent_10)
10
- @child_14 = Factory(:selection, :parent => @parent_10)
11
- @parent_20 = Factory(:selection, :system_code => "priority")
12
- @child_21 = Factory(:selection, :parent => @parent_20, :is_default => true)
13
- @child_22 = Factory(:selection, :parent => @parent_21)
14
-
15
- @company = Factory(:company, :state => @child_14)
16
- assign(:company, @company)
17
- end
18
-
19
- it "should display error when field does not match system_code" do
20
- assign(:field, :not_match)
21
- render
22
- assert_select "form", "Invalid system_code"
23
- end
24
-
25
- context "standard" do
26
- before(:each) do
27
- assign(:field, :state)
28
- assign(:options, nil)
29
- assign(:html_options, nil)
30
- end
31
-
32
- it "selection with default item" do
33
- render
34
- assert_select "form[action='#{company_path(@company)}'][method='post']" do
35
- assert_select "input[type='hidden'][value='put']"
36
- assert_select "select#company_state_id[name='company[state_id]']" do
37
- selected_options(@parent_10.children, @child_14, false)
38
- end
39
- end
40
- end
41
- it "company with no selection set" do
42
- @company.update_attribute(:state, nil)
43
- render
44
- selected_options(@parent_10.children, nil, true)
45
- end
46
- it "selection with archived item" do
47
- @child_13.update_attribute(:archived, true)
48
- render
49
- selected_options(@parent_10.children-[@child_13], @child_14, false)
50
- end
51
- it "company with state set that is archived selection" do
52
- @child_14.update_attribute(:archived, true)
53
- render
54
- selected_options(@parent_10.children, @child_14, false)
55
- end
56
- it "should have blank selection when :include_blank is true" do
57
- assign(:options, {:include_blank => true})
58
- render
59
- selected_options(@parent_10.children, @child_14, true)
60
- end
61
- it "should not have blank when non set and :include_blank is false" do
62
- assign(:options, {:include_blank => false})
63
- @company.update_attribute(:state, nil)
64
- render
65
- selected_options(@parent_10.children, nil, false)
66
- end
67
- it "it should use fieldname which does not match a system_code" do
68
- assign(:options, {:system_code => "state"})
69
- assign(:field, :genre)
70
- @company.update_attribute(:genre_id, @child_14.id)
71
- render
72
- selected_options(@parent_10.children, @child_14, false)
73
- end
74
- end
75
- end
76
- end