dynamic_fieldsets 0.0.16 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. data/.rdebugrc +3 -0
  2. data/.rspec +1 -0
  3. data/CHANGELOG +7 -0
  4. data/Gemfile +17 -8
  5. data/Gemfile.lock +77 -60
  6. data/README.rdoc +1 -1
  7. data/VERSION +1 -1
  8. data/app/controllers/dynamic_fieldsets/fields_controller.rb +5 -4
  9. data/app/helpers/dynamic_fieldsets_helper.rb +48 -131
  10. data/app/models/dynamic_fieldsets.rb +2 -0
  11. data/app/models/dynamic_fieldsets/checkbox_field.rb +29 -0
  12. data/app/models/dynamic_fieldsets/date_field.rb +37 -0
  13. data/app/models/dynamic_fieldsets/datetime_field.rb +36 -0
  14. data/app/models/dynamic_fieldsets/dependency.rb +1 -1
  15. data/app/models/dynamic_fieldsets/dependency_clause.rb +1 -1
  16. data/app/models/dynamic_fieldsets/dependency_group.rb +1 -1
  17. data/app/models/dynamic_fieldsets/field.rb +170 -42
  18. data/app/models/dynamic_fieldsets/field_default.rb +3 -3
  19. data/app/models/dynamic_fieldsets/field_html_attribute.rb +1 -1
  20. data/app/models/dynamic_fieldsets/field_option.rb +1 -1
  21. data/app/models/dynamic_fieldsets/field_record.rb +1 -1
  22. data/app/models/dynamic_fieldsets/fieldset.rb +36 -1
  23. data/app/models/dynamic_fieldsets/fieldset_associator.rb +9 -34
  24. data/app/models/dynamic_fieldsets/fieldset_child.rb +43 -24
  25. data/app/models/dynamic_fieldsets/instruction_field.rb +35 -0
  26. data/app/models/dynamic_fieldsets/multiple_select_field.rb +43 -0
  27. data/app/models/dynamic_fieldsets/radio_field.rb +27 -0
  28. data/app/models/dynamic_fieldsets/select_field.rb +16 -0
  29. data/app/models/dynamic_fieldsets/text_field.rb +14 -0
  30. data/app/models/dynamic_fieldsets/textarea_field.rb +40 -0
  31. data/app/views/dynamic_fieldsets/fields/_form.html.erb +50 -52
  32. data/app/views/dynamic_fieldsets/fields/edit.html.erb +5 -2
  33. data/app/views/dynamic_fieldsets/fields/index.html.erb +1 -1
  34. data/app/views/dynamic_fieldsets/fields/new.html.erb +3 -1
  35. data/app/views/dynamic_fieldsets/fields/show.html.erb +1 -1
  36. data/app/views/dynamic_fieldsets/fieldsets/_child.html.erb +1 -1
  37. data/app/views/dynamic_fieldsets/form_partials/_checkbox_field.html.erb +8 -0
  38. data/app/views/dynamic_fieldsets/form_partials/_date_field.html.erb +1 -0
  39. data/app/views/dynamic_fieldsets/form_partials/_datetime_field.html.erb +1 -0
  40. data/app/views/dynamic_fieldsets/form_partials/_input_footer.html.erb +1 -0
  41. data/app/views/dynamic_fieldsets/form_partials/_input_header.html.erb +7 -0
  42. data/app/views/dynamic_fieldsets/form_partials/_instruction_field.html.erb +1 -0
  43. data/app/views/dynamic_fieldsets/form_partials/_multiple_select_field.html.erb +1 -0
  44. data/app/views/dynamic_fieldsets/form_partials/_radio_field.html.erb +8 -0
  45. data/app/views/dynamic_fieldsets/form_partials/_select_field.html.erb +1 -0
  46. data/app/views/dynamic_fieldsets/form_partials/_text_field.html.erb +1 -0
  47. data/app/views/dynamic_fieldsets/form_partials/_textarea_field.html.erb +1 -0
  48. data/app/views/dynamic_fieldsets/shared/_javascript_watcher.html.erb +8 -8
  49. data/app/views/dynamic_fieldsets/show_partials/_show_incomplete.html.erb +1 -0
  50. data/app/views/dynamic_fieldsets/show_partials/_show_incomplete_footer.html.erb +2 -0
  51. data/app/views/dynamic_fieldsets/show_partials/_show_incomplete_header.html.erb +1 -0
  52. data/app/views/dynamic_fieldsets/show_partials/_show_instruction.html.erb +1 -0
  53. data/app/views/dynamic_fieldsets/show_partials/_show_multiple_answers.html.erb +13 -0
  54. data/app/views/dynamic_fieldsets/show_partials/_show_single_answer.html.erb +8 -0
  55. data/autotest/discover.rb +2 -0
  56. data/dynamic_fieldsets.gemspec +74 -20
  57. data/lib/dynamic_fieldsets/config.rb +45 -0
  58. data/lib/dynamic_fieldsets/dynamic_fieldsets_in_model.rb +38 -63
  59. data/lib/dynamic_fieldsets/field_with_field_options.rb +58 -0
  60. data/lib/dynamic_fieldsets/field_with_multiple_answers.rb +89 -0
  61. data/lib/dynamic_fieldsets/field_with_single_answer.rb +84 -0
  62. data/lib/dynamic_fieldsets/railtie.rb +6 -1
  63. data/lib/generators/dynamic_fieldsets/install_generator.rb +3 -3
  64. data/lib/generators/dynamic_fieldsets/templates/config.rb +15 -0
  65. data/lib/generators/dynamic_fieldsets/templates/migrations/install_migration.rb +1 -1
  66. data/spec/dummy/config/initializers/dynamic_fieldsets.rb +15 -0
  67. data/spec/dummy/db/migrate/20120213211033_create_dynamic_fieldsets_tables.rb +1 -1
  68. data/spec/dummy/db/schema.rb +1 -1
  69. data/spec/dummy/features/step_definitions/field_steps.rb +4 -4
  70. data/spec/dummy/features/step_definitions/fieldset_children_steps.rb +2 -2
  71. data/spec/dummy/features/step_definitions/javascript_steps.rb +7 -7
  72. data/spec/dynamic_fieldsets_helper_spec.rb +278 -312
  73. data/spec/dynamic_fieldsets_in_model_spec.rb +2 -2
  74. data/spec/field_with_field_options_spec.rb +49 -0
  75. data/spec/field_with_multiple_answers_spec.rb +50 -0
  76. data/spec/field_with_single_answer_spec.rb +51 -0
  77. data/spec/models/checkbox_field_spec.rb +19 -0
  78. data/spec/models/date_field_spec.rb +24 -0
  79. data/spec/models/datetime_field_spec.rb +24 -0
  80. data/spec/models/dependency_clause_spec.rb +7 -8
  81. data/spec/models/dependency_group_spec.rb +27 -30
  82. data/spec/models/dependency_spec.rb +8 -9
  83. data/spec/models/field_default_spec.rb +19 -14
  84. data/spec/models/field_html_attribute_spec.rb +3 -4
  85. data/spec/models/field_option_spec.rb +8 -9
  86. data/spec/models/field_record_spec.rb +8 -9
  87. data/spec/models/field_spec.rb +195 -94
  88. data/spec/models/fieldset_associator_spec.rb +39 -41
  89. data/spec/models/fieldset_child_spec.rb +99 -47
  90. data/spec/models/fieldset_spec.rb +25 -29
  91. data/spec/models/instruction_field_spec.rb +38 -0
  92. data/spec/models/multiple_select_field_spec.rb +31 -0
  93. data/spec/models/radio_field_spec.rb +21 -0
  94. data/spec/models/text_field_spec.rb +19 -0
  95. data/spec/models/textarea_field_spec.rb +39 -0
  96. data/spec/support/field_helper.rb +1 -1
  97. metadata +106 -28
@@ -1,17 +1,16 @@
1
1
  require 'spec_helper'
2
- include DynamicFieldsets
3
2
 
4
- describe FieldDefault do
3
+ describe DynamicFieldsets::FieldDefault do
5
4
  include FieldDefaultHelper
6
5
 
7
6
  it "should respond to field" do
8
- field_default = FieldDefault.new
7
+ field_default = DynamicFieldsets::FieldDefault.new
9
8
  field_default.should respond_to :field
10
9
  end
11
10
 
12
11
  describe "validations" do
13
12
  before(:each) do
14
- @field_default = FieldDefault.new
13
+ @field_default = DynamicFieldsets::FieldDefault.new
15
14
  end
16
15
 
17
16
  it "should be valid" do
@@ -28,21 +27,24 @@ describe FieldDefault do
28
27
  # instead of testing the method directly
29
28
  describe "convert_option_name_to_id method" do
30
29
  before(:each) do
31
- @field = Field.new(:field_type => "select")
30
+ @field = DynamicFieldsets::Field.new(:type => "select")
32
31
  @field.stub!(:id).and_return(1)
33
- @field_option = FieldOption.new(:name => "test value")
32
+ @field_option = DynamicFieldsets::FieldOption.new(:name => "test value")
34
33
  @field_option.stub!(:id).and_return(2)
35
- FieldOption.stub!(:find_by_name).and_return(@field_option)
36
- @default = FieldDefault.new(:field => @field, :value => "test value")
34
+ DynamicFieldsets::FieldOption.stub!(:find_by_name).and_return(@field_option)
35
+ @default = DynamicFieldsets::FieldDefault.new(:field => @field, :value => "test value")
37
36
  end
38
37
 
38
+ # removing this validation until the sti code is inplace
39
+ # changed the field name from field_type to type so rails is trying to find models
39
40
  it "should convert the value to a field option id if the field's type is an option type" do
41
+ pending
40
42
  @default.save
41
43
  @default.value.should == @field_option.id
42
44
  end
43
45
 
44
46
  it "should retain it's value if the field's type is not an option type" do
45
- @field.field_type = "textfield"
47
+ @field.type = "textfield"
46
48
  @default.save
47
49
  @default.value.should_not == @field_option.id
48
50
  end
@@ -50,16 +52,19 @@ describe FieldDefault do
50
52
 
51
53
  describe "pretty_value method" do
52
54
  before(:each) do
53
- @field = Field.new(:field_type => "select")
55
+ @field = DynamicFieldsets::Field.new(:type => "select")
54
56
  @field.stub!(:id).and_return(1)
55
- @field_option = FieldOption.new(:name => "test value")
57
+ @field_option = DynamicFieldsets::FieldOption.new(:name => "test value")
56
58
  @field_option.stub!(:id).and_return(2)
57
- FieldOption.stub!(:find_by_name).and_return(@field_option)
58
- @default = FieldDefault.new(:field => @field, :value => "test value")
59
+ DynamicFieldsets::FieldOption.stub!(:find_by_name).and_return(@field_option)
60
+ @default = DynamicFieldsets::FieldDefault.new(:field => @field, :value => "test value")
59
61
  end
60
62
 
63
+ # removing this validation until the sti code is inplace
64
+ # changed the field name from field_type to type so rails is trying to find models
61
65
  it "should return the value if the field is not an option type" do
62
- @field.field_type = "textfield"
66
+ pending
67
+ @field.type = "textfield"
63
68
  @default.pretty_value.should == @default.value
64
69
  end
65
70
 
@@ -1,17 +1,16 @@
1
1
  require 'spec_helper'
2
- include DynamicFieldsets
3
2
 
4
- describe FieldHtmlAttribute do
3
+ describe DynamicFieldsets::FieldHtmlAttribute do
5
4
  include FieldHtmlAttributeHelper
6
5
 
7
6
  it "should respond to field" do
8
- field_html_attribute = FieldHtmlAttribute.new
7
+ field_html_attribute = DynamicFieldsets::FieldHtmlAttribute.new
9
8
  field_html_attribute.should respond_to :field
10
9
  end
11
10
 
12
11
  describe "validations" do
13
12
  before(:each) do
14
- @field_html_attribute = FieldHtmlAttribute.new
13
+ @field_html_attribute = DynamicFieldsets::FieldHtmlAttribute.new
15
14
  end
16
15
 
17
16
  it "should be valid" do
@@ -1,17 +1,16 @@
1
1
  require 'spec_helper'
2
- include DynamicFieldsets
3
-
4
- describe FieldOption do
2
+
3
+ describe DynamicFieldsets::FieldOption do
5
4
  include FieldOptionHelper
6
5
 
7
6
  it "should respond to field" do
8
- field_option = FieldOption.new
7
+ field_option = DynamicFieldsets::FieldOption.new
9
8
  field_option.should respond_to :field
10
9
  end
11
10
 
12
11
  describe "validations" do
13
12
  before(:each) do
14
- @field_option = FieldOption.new
13
+ @field_option = DynamicFieldsets::FieldOption.new
15
14
  end
16
15
 
17
16
  it "should be valid" do
@@ -30,23 +29,23 @@ describe FieldOption do
30
29
 
31
30
  describe "enabled scope" do
32
31
  before(:each) do
33
- @field_option1 = FieldOption.new
32
+ @field_option1 = DynamicFieldsets::FieldOption.new
34
33
  @field_option1.attributes = valid_attributes
35
34
  @field_option1.enabled = true
36
35
  @field_option1.save
37
36
 
38
- @field_option2 = FieldOption.new
37
+ @field_option2 = DynamicFieldsets::FieldOption.new
39
38
  @field_option2.attributes = valid_attributes
40
39
  @field_option2.enabled = false
41
40
  @field_option2.save
42
41
  end
43
42
 
44
43
  it "should return enabled field options" do
45
- FieldOption.enabled.should include @field_option1
44
+ DynamicFieldsets::FieldOption.enabled.should include @field_option1
46
45
  end
47
46
 
48
47
  it "should not return disabled field options" do
49
- FieldOption.enabled.should_not include @field_option2
48
+ DynamicFieldsets::FieldOption.enabled.should_not include @field_option2
50
49
  end
51
50
  end
52
51
  end
@@ -1,28 +1,27 @@
1
1
  require 'spec_helper'
2
- include DynamicFieldsets
3
2
 
4
- describe FieldRecord do
3
+ describe DynamicFieldsets::FieldRecord do
5
4
  include FieldRecordHelper
6
5
 
7
6
  it "should respond to field" do
8
- FieldRecord.new.should respond_to :field
7
+ DynamicFieldsets::FieldRecord.new.should respond_to :field
9
8
  end
10
9
 
11
10
  it "should respond to fieldset_associator" do
12
- FieldRecord.new.should respond_to :fieldset_associator
11
+ DynamicFieldsets::FieldRecord.new.should respond_to :fieldset_associator
13
12
  end
14
13
 
15
14
  describe "validations" do
16
15
  before(:each) do
17
- @field_record = FieldRecord.new
16
+ @field_record = DynamicFieldsets::FieldRecord.new
18
17
  end
19
18
 
20
19
  it "should be valid" do
21
- @field_record.fieldset_child = FieldsetChild.new
22
- @field_record.fieldset_associator = FieldsetAssociator.new
20
+ @field_record.fieldset_child = DynamicFieldsets::FieldsetChild.new
21
+ @field_record.fieldset_associator = DynamicFieldsets::FieldsetAssociator.new
23
22
  @field_record.value = "42"
24
23
  child = mock_model(DynamicFieldsets::Field)
25
- @field_record.fieldset_child = FieldsetChild.new(:child => child)
24
+ @field_record.fieldset_child = DynamicFieldsets::FieldsetChild.new(:child => child)
26
25
  @field_record.should be_valid
27
26
  end
28
27
 
@@ -45,7 +44,7 @@ describe FieldRecord do
45
44
 
46
45
  it "should error if the fieldset_child has the wrong type" do
47
46
  child = mock_model(DynamicFieldsets::Fieldset)
48
- @field_record.fieldset_child = FieldsetChild.new(:child => child)
47
+ @field_record.fieldset_child = DynamicFieldsets::FieldsetChild.new(:child => child)
49
48
  @field_record.valid?
50
49
  @field_record.should have(1).error_on(:fieldset_child)
51
50
  end
@@ -1,33 +1,41 @@
1
1
  require 'spec_helper'
2
- include DynamicFieldsets
3
2
 
4
- describe Field do
3
+ describe DynamicFieldsets::Field do
5
4
  include FieldHelper
6
5
 
7
- it "should respond to parent_fieldset" do
8
- Field.new.should respond_to :parent_fieldsets
6
+ before do
7
+ @field = DynamicFieldsets::Field.new
9
8
  end
10
-
11
- it "should respond to field_options" do
12
- Field.new.should respond_to :field_options
9
+ subject { @field }
10
+
11
+ describe "fields" do
12
+ it { should respond_to :name }
13
+ it { should respond_to :label }
14
+ it { should respond_to :type }
15
+ it { should respond_to :required }
16
+ it { should respond_to :enabled }
13
17
  end
14
18
 
15
- it "should respond to field_defaults" do
16
- Field.new.should respond_to :field_defaults
17
- end
19
+ describe "associations" do
20
+ before do
21
+ pending "shoulda installation"
22
+ end
18
23
 
19
- it "should respond to field_html_attributes" do
20
- Field.new.should respond_to :field_html_attributes
24
+ it { should have_many :fieldset_children }
25
+ it { should have_many :parent_fieldsets }
26
+ it { should have_many :field_options }
27
+ it { should have_many :field_defaults }
28
+ it { should have_many :field_html_attributes }
21
29
  end
22
30
 
23
31
  describe "validations" do
24
32
  before(:each) do
25
- @field = Field.new
33
+ @field = DynamicFieldsets::Field.new
26
34
  end
27
35
 
28
- it "should be valid" do
36
+ it "should not be valid because it should be instantiated through the child classes" do
29
37
  @field.attributes = valid_attributes
30
- @field.should be_valid
38
+ @field.should_not be_valid
31
39
  end
32
40
 
33
41
  it "should require name" do
@@ -38,21 +46,10 @@ describe Field do
38
46
  @field.should have(1).error_on(:label)
39
47
  end
40
48
 
41
- it "should require field_type" do
42
- @field.should have(2).error_on(:field_type)
43
- end
44
-
45
- it "should require type within the allowable types" do
46
- @field.field_type = "unsupported_type"
47
- @field.should have(1).error_on(:field_type)
49
+ it "should require type" do
50
+ @field.should have(1).error_on(:type)
48
51
  end
49
52
 
50
- it "should require type within the allowable types" do
51
- @field.field_type = "select"
52
- @field.should have(0).error_on(:field_type)
53
- end
54
-
55
-
56
53
  it "should require enabled true or false" do
57
54
  @field.enabled = true
58
55
  @field.should have(0).error_on(:enabled)
@@ -63,48 +60,111 @@ describe Field do
63
60
  @field.should have(0).error_on(:required)
64
61
  end
65
62
 
63
+ # this validation now comes from the field option mixin
64
+ # whenever we get around to tests, this needs to be moved over.
65
+ # lets see how long this takes (JH 2-27-2012)
66
66
  it "should require options if the type is one that requires options" do
67
- @field.field_type = "select"
67
+ pending "this needs to be moved to the field option mixin"
68
+ @field.type = "select"
68
69
  @field.should have(1).error_on(:field_options)
69
70
  end
70
71
  end
71
72
 
72
- describe "options?" do
73
- before(:each) do
74
- @field = Field.new
73
+ # Scopes and Static Methods
74
+
75
+ it { DynamicFieldsets::Field.should respond_to :descendants }
76
+ describe ".descendants" do
77
+ it "should call super if cache classes is on"
78
+ it "should call the config if cache classes is off"
79
+ end
80
+
81
+ it { DynamicFieldsets::Field.should respond_to :descendant_collection }
82
+ describe ".descendant_collection" do
83
+ it "should call descendants"
84
+ it "should convert the class names to humanized strings"
85
+ end
86
+
87
+ describe "form partial methods" do
88
+ it { should respond_to :form_partial }
89
+ describe ".form_partial" do
90
+ it "needs tests"
91
+ end
92
+
93
+ it { should respond_to :form_header_partial }
94
+ describe ".form_header_partial" do
95
+ it "needs tests"
75
96
  end
76
97
 
77
- it "should return true if the field type requires options" do
78
- @field.field_type = "select"
79
- @field.options?.should be_true
98
+ it { should respond_to :use_form_header_partial? }
99
+ describe ".use_form_header_partial?" do
100
+ it "needs tests"
80
101
  end
81
102
 
82
- it "should return false if the field does not have options" do
83
- @field.field_type = "textfield"
84
- @field.options?.should be_false
103
+ it { should respond_to :form_footer_partial }
104
+ describe ".form_footer_partial" do
105
+ it "needs tests"
106
+ end
107
+
108
+ it { should respond_to :use_form_footer_partial? }
109
+ describe ".use_form_footer_partial?" do
110
+ it "needs tests"
111
+ end
112
+
113
+ it { should respond_to :form_partial_locals }
114
+ describe ".form_partial_locals" do
115
+ it "needs tests"
116
+ end
117
+
118
+ it { should respond_to :html_attribute_hash }
119
+ describe ".html_attribute_hash" do
120
+ it "needs tests"
85
121
  end
86
122
  end
87
123
 
88
- describe "options" do
89
- it "should return options from the field options table if enabled" do
90
- field = Field.new
91
- field_option = mock_model(DynamicFieldsets::FieldOption)
92
- field_option.stub!(:enabled).and_return(true)
93
- field.should_receive(:field_options).and_return([field_option])
94
- field.options.should include field_option
124
+ describe "show partial methods" do
125
+
126
+ it { should respond_to :show_partial }
127
+ describe ".show_partial" do
128
+ it "needs tests"
95
129
  end
96
- it "should not return disabled options from the field options table" do
97
- field = Field.new
98
- field_option = mock_model(DynamicFieldsets::FieldOption)
99
- field_option.stub!(:enabled).and_return(false)
100
- field.should_receive(:field_options).and_return([field_option])
101
- field.options.should_not include field_option
130
+
131
+ it { should respond_to :show_header_partial }
132
+ describe ".show_header_partial" do
133
+ it "needs tests"
134
+ end
135
+
136
+ it { should respond_to :use_show_header_partial? }
137
+ describe ".use_show_header_partial?" do
138
+ it "needs tests"
139
+ end
140
+
141
+ it { should respond_to :show_footer_partial }
142
+ describe ".show_footer_partial" do
143
+ it "needs tests"
144
+ end
145
+
146
+ it { should respond_to :use_show_footer_partial? }
147
+ describe ".use_show_footer_partial?" do
148
+ it "needs tests"
149
+ end
150
+
151
+ it { should respond_to :show_partial_locals }
152
+ describe ".show_partial_locals" do
153
+ it "needs tests"
154
+ end
155
+
156
+ it { should respond_to :get_value_for_show }
157
+ describe ".get_value_for_show" do
158
+ it "needs tests"
102
159
  end
103
160
  end
104
161
 
162
+ # other methods
163
+
164
+ it { should respond_to :has_defaults? }
105
165
  describe "has_defaults?" do
106
166
  before(:each) do
107
- @field = Field.new
167
+ @field = DynamicFieldsets::Field.new
108
168
  end
109
169
 
110
170
  it "should return true if the field default has a value" do
@@ -117,9 +177,89 @@ describe Field do
117
177
  end
118
178
  end
119
179
 
180
+ it { should respond_to :in_use? }
181
+ describe "in_use? method" do
182
+ before(:each) do
183
+ @field = DynamicFieldsets::Field.new
184
+ @field.stub!(:id).and_return(1)
185
+
186
+ end
187
+ it "should return true if there is a field record associated with the field" do
188
+ @fieldset_child = DynamicFieldsets::FieldsetChild.new(:child => @field, :fieldset => nil )
189
+ @fieldset_child.stub!(:field_records).and_return(["random", "array" "of", "stuff"])
190
+ @field.stub!(:fieldset_children).and_return([@fieldset_child])
191
+
192
+ @field.in_use?.should be_true
193
+ end
194
+
195
+ it "should return true if the field is in a fieldset (through a fieldset child)" do
196
+ @fieldset = DynamicFieldsets::Fieldset.new
197
+ @fieldset.stub!(:id).and_return(2)
198
+ @fieldset_child = DynamicFieldsets::FieldsetChild.new(:child => @field, :fieldset_id => @fieldset.id)
199
+ @field.stub!(:fieldset_children).and_return([@fieldset_child])
200
+
201
+ @field.in_use?.should be_true
202
+ end
203
+
204
+ it "should return false otherwise" do
205
+ @field.in_use?.should be_false
206
+ end
207
+ end
208
+
209
+ it { should respond_to :uses_field_options? }
210
+ describe ".uses_field_options?" do
211
+ it "should return false" do
212
+ @field.uses_field_options?.should be_false
213
+ end
214
+ end
215
+
216
+ it { should respond_to :collect_default_values }
217
+ describe ".collect_default_values" do
218
+ it "needs tests"
219
+ end
220
+
221
+ it { should respond_to :get_values_using_fsa_and_fsc }
222
+ describe ".get_values_using_fsa_and_fsc" do
223
+ it "needs tests"
224
+ end
225
+
226
+ it { should respond_to :collect_field_records_by_fsa_and_fsc }
227
+ describe ".collect_field_records_by_fsa_and_fsc" do
228
+ it "needs tests"
229
+ end
230
+
231
+ it { should respond_to :update_field_records }
232
+ describe ".update_field_records" do
233
+ it "should throw an error" do
234
+ lambda { @field.update_field_records }.should raise_exception
235
+ end
236
+ end
237
+
238
+ describe "options" do
239
+ before do
240
+ pending "This code has been moved to the field option mixin"
241
+ end
242
+
243
+ it "should return options from the field options table if enabled" do
244
+ field = DynamicFieldsets::Field.new
245
+ field_option = mock_model(DynamicFieldsets::FieldOption)
246
+ field_option.stub!(:enabled).and_return(true)
247
+ field.should_receive(:field_options).and_return([field_option])
248
+ field.options.should include field_option
249
+ end
250
+ it "should not return disabled options from the field options table" do
251
+ field = DynamicFieldsets::Field.new
252
+ field_option = mock_model(DynamicFieldsets::FieldOption)
253
+ field_option.stub!(:enabled).and_return(false)
254
+ field.should_receive(:field_options).and_return([field_option])
255
+ field.options.should_not include field_option
256
+ end
257
+ end
258
+
120
259
  describe "default" do
121
260
  before(:each) do
122
- @field = Field.new
261
+ pending "this code has been moved to the single answer mixin"
262
+ @field = DynamicFieldsets::Field.new
123
263
  end
124
264
 
125
265
  it "should return a string if the type does not support multiple options" do
@@ -136,7 +276,8 @@ describe Field do
136
276
 
137
277
  describe "defaults" do
138
278
  before(:each) do
139
- @field = Field.new
279
+ pending "this code has been moved to the multiple answer mixin"
280
+ @field = DynamicFieldsets::Field.new
140
281
  end
141
282
 
142
283
  it "should return an array if the type supports multiple options" do
@@ -150,44 +291,4 @@ describe Field do
150
291
  @field.defaults.should be_nil
151
292
  end
152
293
  end
153
-
154
- describe "field_types method" do
155
- it "should return an array" do
156
- Field.field_types.should be_a_kind_of Array
157
- end
158
- end
159
-
160
- describe "option_field_types method" do
161
- it "should return an array" do
162
- Field.option_field_types.should be_a_kind_of Array
163
- end
164
- end
165
-
166
- describe "in_use? method" do
167
- before(:each) do
168
- @field = Field.new
169
- @field.stub!(:id).and_return(1)
170
-
171
- end
172
- it "should return true if there is a field record associated with the field" do
173
- @fieldset_child = FieldsetChild.new(:child => @field, :fieldset => nil )
174
- @fieldset_child.stub!(:field_records).and_return(["random", "array" "of", "stuff"])
175
- @field.stub!(:fieldset_children).and_return([@fieldset_child])
176
-
177
- @field.in_use?.should be_true
178
- end
179
-
180
- it "should return true if the field is in a fieldset (through a fieldset child)" do
181
- @fieldset = Fieldset.new
182
- @fieldset.stub!(:id).and_return(2)
183
- @fieldset_child = FieldsetChild.new(:child => @field, :fieldset_id => @fieldset.id)
184
- @field.stub!(:fieldset_children).and_return([@fieldset_child])
185
-
186
- @field.in_use?.should be_true
187
- end
188
-
189
- it "should return false otherwise" do
190
- @field.in_use?.should be_false
191
- end
192
- end
193
294
  end