dynamic_fieldsets 0.0.16 → 0.1.0
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/.rdebugrc +3 -0
- data/.rspec +1 -0
- data/CHANGELOG +7 -0
- data/Gemfile +17 -8
- data/Gemfile.lock +77 -60
- data/README.rdoc +1 -1
- data/VERSION +1 -1
- data/app/controllers/dynamic_fieldsets/fields_controller.rb +5 -4
- data/app/helpers/dynamic_fieldsets_helper.rb +48 -131
- data/app/models/dynamic_fieldsets.rb +2 -0
- data/app/models/dynamic_fieldsets/checkbox_field.rb +29 -0
- data/app/models/dynamic_fieldsets/date_field.rb +37 -0
- data/app/models/dynamic_fieldsets/datetime_field.rb +36 -0
- data/app/models/dynamic_fieldsets/dependency.rb +1 -1
- data/app/models/dynamic_fieldsets/dependency_clause.rb +1 -1
- data/app/models/dynamic_fieldsets/dependency_group.rb +1 -1
- data/app/models/dynamic_fieldsets/field.rb +170 -42
- data/app/models/dynamic_fieldsets/field_default.rb +3 -3
- data/app/models/dynamic_fieldsets/field_html_attribute.rb +1 -1
- data/app/models/dynamic_fieldsets/field_option.rb +1 -1
- data/app/models/dynamic_fieldsets/field_record.rb +1 -1
- data/app/models/dynamic_fieldsets/fieldset.rb +36 -1
- data/app/models/dynamic_fieldsets/fieldset_associator.rb +9 -34
- data/app/models/dynamic_fieldsets/fieldset_child.rb +43 -24
- data/app/models/dynamic_fieldsets/instruction_field.rb +35 -0
- data/app/models/dynamic_fieldsets/multiple_select_field.rb +43 -0
- data/app/models/dynamic_fieldsets/radio_field.rb +27 -0
- data/app/models/dynamic_fieldsets/select_field.rb +16 -0
- data/app/models/dynamic_fieldsets/text_field.rb +14 -0
- data/app/models/dynamic_fieldsets/textarea_field.rb +40 -0
- data/app/views/dynamic_fieldsets/fields/_form.html.erb +50 -52
- data/app/views/dynamic_fieldsets/fields/edit.html.erb +5 -2
- data/app/views/dynamic_fieldsets/fields/index.html.erb +1 -1
- data/app/views/dynamic_fieldsets/fields/new.html.erb +3 -1
- data/app/views/dynamic_fieldsets/fields/show.html.erb +1 -1
- data/app/views/dynamic_fieldsets/fieldsets/_child.html.erb +1 -1
- data/app/views/dynamic_fieldsets/form_partials/_checkbox_field.html.erb +8 -0
- data/app/views/dynamic_fieldsets/form_partials/_date_field.html.erb +1 -0
- data/app/views/dynamic_fieldsets/form_partials/_datetime_field.html.erb +1 -0
- data/app/views/dynamic_fieldsets/form_partials/_input_footer.html.erb +1 -0
- data/app/views/dynamic_fieldsets/form_partials/_input_header.html.erb +7 -0
- data/app/views/dynamic_fieldsets/form_partials/_instruction_field.html.erb +1 -0
- data/app/views/dynamic_fieldsets/form_partials/_multiple_select_field.html.erb +1 -0
- data/app/views/dynamic_fieldsets/form_partials/_radio_field.html.erb +8 -0
- data/app/views/dynamic_fieldsets/form_partials/_select_field.html.erb +1 -0
- data/app/views/dynamic_fieldsets/form_partials/_text_field.html.erb +1 -0
- data/app/views/dynamic_fieldsets/form_partials/_textarea_field.html.erb +1 -0
- data/app/views/dynamic_fieldsets/shared/_javascript_watcher.html.erb +8 -8
- data/app/views/dynamic_fieldsets/show_partials/_show_incomplete.html.erb +1 -0
- data/app/views/dynamic_fieldsets/show_partials/_show_incomplete_footer.html.erb +2 -0
- data/app/views/dynamic_fieldsets/show_partials/_show_incomplete_header.html.erb +1 -0
- data/app/views/dynamic_fieldsets/show_partials/_show_instruction.html.erb +1 -0
- data/app/views/dynamic_fieldsets/show_partials/_show_multiple_answers.html.erb +13 -0
- data/app/views/dynamic_fieldsets/show_partials/_show_single_answer.html.erb +8 -0
- data/autotest/discover.rb +2 -0
- data/dynamic_fieldsets.gemspec +74 -20
- data/lib/dynamic_fieldsets/config.rb +45 -0
- data/lib/dynamic_fieldsets/dynamic_fieldsets_in_model.rb +38 -63
- data/lib/dynamic_fieldsets/field_with_field_options.rb +58 -0
- data/lib/dynamic_fieldsets/field_with_multiple_answers.rb +89 -0
- data/lib/dynamic_fieldsets/field_with_single_answer.rb +84 -0
- data/lib/dynamic_fieldsets/railtie.rb +6 -1
- data/lib/generators/dynamic_fieldsets/install_generator.rb +3 -3
- data/lib/generators/dynamic_fieldsets/templates/config.rb +15 -0
- data/lib/generators/dynamic_fieldsets/templates/migrations/install_migration.rb +1 -1
- data/spec/dummy/config/initializers/dynamic_fieldsets.rb +15 -0
- data/spec/dummy/db/migrate/20120213211033_create_dynamic_fieldsets_tables.rb +1 -1
- data/spec/dummy/db/schema.rb +1 -1
- data/spec/dummy/features/step_definitions/field_steps.rb +4 -4
- data/spec/dummy/features/step_definitions/fieldset_children_steps.rb +2 -2
- data/spec/dummy/features/step_definitions/javascript_steps.rb +7 -7
- data/spec/dynamic_fieldsets_helper_spec.rb +278 -312
- data/spec/dynamic_fieldsets_in_model_spec.rb +2 -2
- data/spec/field_with_field_options_spec.rb +49 -0
- data/spec/field_with_multiple_answers_spec.rb +50 -0
- data/spec/field_with_single_answer_spec.rb +51 -0
- data/spec/models/checkbox_field_spec.rb +19 -0
- data/spec/models/date_field_spec.rb +24 -0
- data/spec/models/datetime_field_spec.rb +24 -0
- data/spec/models/dependency_clause_spec.rb +7 -8
- data/spec/models/dependency_group_spec.rb +27 -30
- data/spec/models/dependency_spec.rb +8 -9
- data/spec/models/field_default_spec.rb +19 -14
- data/spec/models/field_html_attribute_spec.rb +3 -4
- data/spec/models/field_option_spec.rb +8 -9
- data/spec/models/field_record_spec.rb +8 -9
- data/spec/models/field_spec.rb +195 -94
- data/spec/models/fieldset_associator_spec.rb +39 -41
- data/spec/models/fieldset_child_spec.rb +99 -47
- data/spec/models/fieldset_spec.rb +25 -29
- data/spec/models/instruction_field_spec.rb +38 -0
- data/spec/models/multiple_select_field_spec.rb +31 -0
- data/spec/models/radio_field_spec.rb +21 -0
- data/spec/models/text_field_spec.rb +19 -0
- data/spec/models/textarea_field_spec.rb +39 -0
- data/spec/support/field_helper.rb +1 -1
- metadata +106 -28
|
@@ -44,7 +44,7 @@ describe DynamicFieldsetsInModel do
|
|
|
44
44
|
|
|
45
45
|
describe "run_dynamic_fieldset_validations! method" do
|
|
46
46
|
before(:each) do
|
|
47
|
-
@field = Field.new(:name => "Test Field", :label => "Test Field", :
|
|
47
|
+
@field = Field.new(:name => "Test Field", :label => "Test Field", :type => "textfield")
|
|
48
48
|
@fieldset = Fieldset.new(:name => "first", :nkey => "first", :description => "description")
|
|
49
49
|
@fieldset.stub!(:children).and_return([@field])
|
|
50
50
|
@fsa = FieldsetAssociator.new
|
|
@@ -70,7 +70,7 @@ describe DynamicFieldsetsInModel do
|
|
|
70
70
|
|
|
71
71
|
describe "run_fieldset_child_validations! method" do
|
|
72
72
|
before(:each) do
|
|
73
|
-
@field = Field.new(:name => "Test Field", :label => "Test Field", :
|
|
73
|
+
@field = Field.new(:name => "Test Field", :label => "Test Field", :type => "textfield", :required => true)
|
|
74
74
|
@field.stub!(:id).and_return(42)
|
|
75
75
|
@fieldset = Fieldset.new(:name => "first", :nkey => "first", :description => "description")
|
|
76
76
|
@fieldset.stub!(:children).and_return([@field])
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
include DynamicFieldsets
|
|
4
|
+
|
|
5
|
+
describe FieldWithFieldOptions do
|
|
6
|
+
it "should not use CheckboxField to test the mixin" do
|
|
7
|
+
pending "needs to use it's own class"
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
describe "class methods" do
|
|
11
|
+
it { DynamicFieldsets::CheckboxField.should respond_to :acts_as_field_with_field_options }
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
describe "validations" do
|
|
15
|
+
it "should call at_least_one_field_option"
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
describe "instance methods" do
|
|
19
|
+
before do
|
|
20
|
+
@field = DynamicFieldsets::CheckboxField.new
|
|
21
|
+
end
|
|
22
|
+
subject { @field }
|
|
23
|
+
|
|
24
|
+
it { should respond_to :collect_field_records_by_fsa_and_fsc }
|
|
25
|
+
describe "collect_field_records_by_fsa_and_fsc" do
|
|
26
|
+
it "needs tests"
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it { should respond_to :get_value_for_show }
|
|
30
|
+
describe ".get_value_for_show" do
|
|
31
|
+
it "needs tests"
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it { should respond_to :uses_field_options? }
|
|
35
|
+
describe ".uses_field_options?" do
|
|
36
|
+
it "needs tests"
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it { should respond_to :at_least_one_field_option }
|
|
40
|
+
describe ".at_least_one_field_option" do
|
|
41
|
+
it " needs tests"
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it { should respond_to :options }
|
|
45
|
+
describe ".options" do
|
|
46
|
+
it "needs tests"
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
include DynamicFieldsets
|
|
4
|
+
|
|
5
|
+
describe FieldWithMultipleAnswers do
|
|
6
|
+
it "should not use CheckboxField to test the mixin" do
|
|
7
|
+
pending "needs to use it's own class"
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
describe "class methods" do
|
|
11
|
+
it { DynamicFieldsets::CheckboxField.should respond_to :acts_as_field_with_multiple_answers }
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
describe "instance methods" do
|
|
15
|
+
before do
|
|
16
|
+
@field = DynamicFieldsets::CheckboxField.new
|
|
17
|
+
end
|
|
18
|
+
subject { @field }
|
|
19
|
+
|
|
20
|
+
it { should respond_to :show_partial_locals }
|
|
21
|
+
describe ".show_partial_locals" do
|
|
22
|
+
it "needs tests"
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it { should respond_to :update_field_records }
|
|
26
|
+
describe ".update_field_records" do
|
|
27
|
+
it "needs tests"
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it { should respond_to :get_values_using_fsa_and_fsc }
|
|
31
|
+
describe ".get_values_using_fsa_and_fsc" do
|
|
32
|
+
it "needs tests"
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it { should respond_to :show_partial }
|
|
36
|
+
describe ".show_partial" do
|
|
37
|
+
it "needs tests"
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it { should respond_to :defaults }
|
|
41
|
+
describe ".defaults" do
|
|
42
|
+
it "needs tests"
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it { should respond_to :values_or_defaults_for_form }
|
|
46
|
+
describe ".values_or_defaults_for_form" do
|
|
47
|
+
it "needs tests"
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
include DynamicFieldsets
|
|
4
|
+
|
|
5
|
+
describe DynamicFieldsets::FieldWithSingleAnswer do
|
|
6
|
+
|
|
7
|
+
it "should not use TextField to test the mixin" do
|
|
8
|
+
pending "needs to use it's own class"
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
describe "class methods" do
|
|
12
|
+
it { DynamicFieldsets::TextField.should respond_to :acts_as_field_with_single_answer }
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
describe "instance methods" do
|
|
16
|
+
before do
|
|
17
|
+
@field = DynamicFieldsets::TextField.new
|
|
18
|
+
end
|
|
19
|
+
subject { @field }
|
|
20
|
+
|
|
21
|
+
it { should respond_to :show_partial_locals }
|
|
22
|
+
describe ".show_partial_locals" do
|
|
23
|
+
it "needs tests"
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it { should respond_to :update_field_records }
|
|
27
|
+
describe ".update_field_records" do
|
|
28
|
+
it "needs tests"
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it { should respond_to :get_values_using_fsa_and_fsc }
|
|
32
|
+
describe ".get_values_using_fsa_and_fsc" do
|
|
33
|
+
it "needs tests"
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it { should respond_to :show_partial }
|
|
37
|
+
describe ".show_partial" do
|
|
38
|
+
it "needs tests"
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it { should respond_to :default }
|
|
42
|
+
describe ".default" do
|
|
43
|
+
it "needs tests"
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it { should respond_to :value_or_default_for_form }
|
|
47
|
+
describe ".value_or_default_for_form" do
|
|
48
|
+
it "needs tests"
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe DynamicFieldsets::CheckboxField do
|
|
4
|
+
before do
|
|
5
|
+
@checkbox = DynamicFieldsets::CheckboxField.new
|
|
6
|
+
end
|
|
7
|
+
subject { @checkbox }
|
|
8
|
+
|
|
9
|
+
describe "mixins" do
|
|
10
|
+
it "should include the field options mixin"
|
|
11
|
+
it "should include the multiple answers mixin"
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# instance methods
|
|
15
|
+
describe ".form_partial_locals" do
|
|
16
|
+
it "should call super"
|
|
17
|
+
it "should do a bunch of stuff with the options key"
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe DynamicFieldsets::DateField do
|
|
4
|
+
before do
|
|
5
|
+
@date = DynamicFieldsets::DateField.new
|
|
6
|
+
end
|
|
7
|
+
subject { @date }
|
|
8
|
+
|
|
9
|
+
describe "mixins" do
|
|
10
|
+
it "should include the single answer mixin"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# instance methods
|
|
14
|
+
it { should respond_to :get_date_or_today }
|
|
15
|
+
describe ".get_date_or_today" do
|
|
16
|
+
it "should return the inputted date"
|
|
17
|
+
it "should return today if the inputted date is empty"
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
describe ".form_partial_locals" do
|
|
21
|
+
it "should call super"
|
|
22
|
+
it "should include start year and default in the output"
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe DynamicFieldsets::DatetimeField do
|
|
4
|
+
before do
|
|
5
|
+
@datetime = DynamicFieldsets::DatetimeField.new
|
|
6
|
+
end
|
|
7
|
+
subject { @datetime }
|
|
8
|
+
|
|
9
|
+
describe "mixins" do
|
|
10
|
+
it "should include the single answer mixin"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# instance methods
|
|
14
|
+
it { should respond_to :get_datetime_or_today }
|
|
15
|
+
describe ".get_datetime_or_today" do
|
|
16
|
+
it "should return the inputted datetime"
|
|
17
|
+
it "should return today if the inputted datetime is empty"
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
describe ".form_partial_locals" do
|
|
21
|
+
it "should call super"
|
|
22
|
+
it "should include start year and default in the output"
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
|
-
include DynamicFieldsets
|
|
3
2
|
|
|
4
|
-
describe DependencyClause do
|
|
3
|
+
describe DynamicFieldsets::DependencyClause do
|
|
5
4
|
it "should respond to dependency_group" do
|
|
6
|
-
DependencyClause.new.should respond_to :dependency_group
|
|
5
|
+
DynamicFieldsets::DependencyClause.new.should respond_to :dependency_group
|
|
7
6
|
end
|
|
8
7
|
|
|
9
8
|
it "should respond to dependencies" do
|
|
10
|
-
DependencyClause.new.should respond_to :dependencies
|
|
9
|
+
DynamicFieldsets::DependencyClause.new.should respond_to :dependencies
|
|
11
10
|
end
|
|
12
11
|
|
|
13
12
|
describe "validations" do
|
|
14
13
|
before(:each) do
|
|
15
|
-
@clause = DependencyClause.new
|
|
14
|
+
@clause = DynamicFieldsets::DependencyClause.new
|
|
16
15
|
end
|
|
17
16
|
|
|
18
17
|
it "should be valid" do
|
|
@@ -27,9 +26,9 @@ describe DependencyClause do
|
|
|
27
26
|
|
|
28
27
|
describe "evaluate" do
|
|
29
28
|
before(:each) do
|
|
30
|
-
@clause = DependencyClause.new
|
|
31
|
-
@dependency1 = Dependency.new
|
|
32
|
-
@dependency2 = Dependency.new
|
|
29
|
+
@clause = DynamicFieldsets::DependencyClause.new
|
|
30
|
+
@dependency1 = DynamicFieldsets::Dependency.new
|
|
31
|
+
@dependency2 = DynamicFieldsets::Dependency.new
|
|
33
32
|
@clause.stub!(:dependencies).and_return([@dependency1, @dependency2])
|
|
34
33
|
@evaluate_args = {}
|
|
35
34
|
end
|
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
|
-
include DynamicFieldsets
|
|
3
2
|
|
|
4
|
-
describe DependencyGroup do
|
|
3
|
+
describe DynamicFieldsets::DependencyGroup do
|
|
5
4
|
include DependencyGroupHelper
|
|
6
5
|
|
|
7
6
|
it "should respond to fieldset_child" do
|
|
8
|
-
DependencyGroup.new.should respond_to :fieldset_child
|
|
7
|
+
DynamicFieldsets::DependencyGroup.new.should respond_to :fieldset_child
|
|
9
8
|
end
|
|
10
9
|
|
|
11
10
|
it "should respond to dependency_clauses" do
|
|
12
|
-
DependencyGroup.new.should respond_to :dependency_clauses
|
|
11
|
+
DynamicFieldsets::DependencyGroup.new.should respond_to :dependency_clauses
|
|
13
12
|
end
|
|
14
13
|
|
|
15
14
|
describe "validations" do
|
|
16
15
|
before(:each) do
|
|
17
|
-
@group = DependencyGroup.new
|
|
16
|
+
@group = DynamicFieldsets::DependencyGroup.new
|
|
18
17
|
end
|
|
19
18
|
|
|
20
19
|
it "should be valid" do
|
|
@@ -38,19 +37,19 @@ describe DependencyGroup do
|
|
|
38
37
|
|
|
39
38
|
describe "action_list method" do
|
|
40
39
|
it "should return an hash" do
|
|
41
|
-
DependencyGroup.new.action_list.should be_a_kind_of(Hash)
|
|
40
|
+
DynamicFieldsets::DependencyGroup.new.action_list.should be_a_kind_of(Hash)
|
|
42
41
|
end
|
|
43
42
|
end
|
|
44
43
|
|
|
45
44
|
describe "dependency_group_fieldset_chldren method" do
|
|
46
45
|
before(:each) do
|
|
47
|
-
@fieldset_child_1 = FieldsetChild.create(:fieldset_id => 1, :child_id => 1, :child_type => "DynamicFieldsets::Field", :order_num => 1)
|
|
48
|
-
@fieldset_child_2 = FieldsetChild.create(:fieldset_id => 2, :child_id => 2, :child_type => "DynamicFieldsets::Field", :order_num => 2)
|
|
49
|
-
@fieldset_child_3 = FieldsetChild.create(:fieldset_id => 3, :child_id => 3, :child_type => "DynamicFieldsets::Field", :order_num => 3)
|
|
50
|
-
@group = DependencyGroup.create(:fieldset_child => @fieldset_child_3, :action => "show")
|
|
51
|
-
@clause = DependencyClause.create(:dependency_group => @group)
|
|
52
|
-
@dependency_1 = Dependency.create(:fieldset_child => @fieldset_child_1, :dependency_clause => @clause, :value => "5", :relationship => "equals")
|
|
53
|
-
@dependency_2 = Dependency.create(:fieldset_child => @fieldset_child_2, :dependency_clause => @clause, :value => "5", :relationship => "equals")
|
|
46
|
+
@fieldset_child_1 = DynamicFieldsets::FieldsetChild.create(:fieldset_id => 1, :child_id => 1, :child_type => "DynamicFieldsets::Field", :order_num => 1)
|
|
47
|
+
@fieldset_child_2 = DynamicFieldsets::FieldsetChild.create(:fieldset_id => 2, :child_id => 2, :child_type => "DynamicFieldsets::Field", :order_num => 2)
|
|
48
|
+
@fieldset_child_3 = DynamicFieldsets::FieldsetChild.create(:fieldset_id => 3, :child_id => 3, :child_type => "DynamicFieldsets::Field", :order_num => 3)
|
|
49
|
+
@group = DynamicFieldsets::DependencyGroup.create(:fieldset_child => @fieldset_child_3, :action => "show")
|
|
50
|
+
@clause = DynamicFieldsets::DependencyClause.create(:dependency_group => @group)
|
|
51
|
+
@dependency_1 = DynamicFieldsets::Dependency.create(:fieldset_child => @fieldset_child_1, :dependency_clause => @clause, :value => "5", :relationship => "equals")
|
|
52
|
+
@dependency_2 = DynamicFieldsets::Dependency.create(:fieldset_child => @fieldset_child_2, :dependency_clause => @clause, :value => "5", :relationship => "equals")
|
|
54
53
|
@input_hash = JSON.parse(@group.dependency_group_fieldset_children)
|
|
55
54
|
end
|
|
56
55
|
|
|
@@ -67,11 +66,11 @@ describe DependencyGroup do
|
|
|
67
66
|
|
|
68
67
|
describe "dependent_fieldset_children method" do
|
|
69
68
|
before(:each) do
|
|
70
|
-
@group = DependencyGroup.new
|
|
69
|
+
@group = DynamicFieldsets::DependencyGroup.new
|
|
71
70
|
@group.attributes = valid_attributes
|
|
72
71
|
@group.save
|
|
73
|
-
@clause = DependencyClause.create(:dependency_group => @group)
|
|
74
|
-
@dependency = Dependency.create(:value => 5, :relationship => "equals", :dependency_clause => @clause, :fieldset_child_id => 42)
|
|
72
|
+
@clause = DynamicFieldsets::DependencyClause.create(:dependency_group => @group)
|
|
73
|
+
@dependency = DynamicFieldsets::Dependency.create(:value => 5, :relationship => "equals", :dependency_clause => @clause, :fieldset_child_id => 42)
|
|
75
74
|
end
|
|
76
75
|
|
|
77
76
|
it "should return an array" do
|
|
@@ -90,7 +89,7 @@ describe DependencyGroup do
|
|
|
90
89
|
|
|
91
90
|
describe "get_action method" do
|
|
92
91
|
before(:each) do
|
|
93
|
-
@group = DependencyGroup.new
|
|
92
|
+
@group = DynamicFieldsets::DependencyGroup.new
|
|
94
93
|
@group.stub!(:evaluate).and_return(true)
|
|
95
94
|
@group.action = "show"
|
|
96
95
|
end
|
|
@@ -111,9 +110,9 @@ describe DependencyGroup do
|
|
|
111
110
|
|
|
112
111
|
describe "evaluate method" do
|
|
113
112
|
before(:each) do
|
|
114
|
-
@group = DependencyGroup.new
|
|
115
|
-
@clause1 = DependencyClause.new
|
|
116
|
-
@clause2 = DependencyClause.new
|
|
113
|
+
@group = DynamicFieldsets::DependencyGroup.new
|
|
114
|
+
@clause1 = DynamicFieldsets::DependencyClause.new
|
|
115
|
+
@clause2 = DynamicFieldsets::DependencyClause.new
|
|
117
116
|
@group.stub!(:dependency_clauses).and_return([@clause1, @clause2])
|
|
118
117
|
@input_values = {}
|
|
119
118
|
end
|
|
@@ -138,24 +137,24 @@ describe DependencyGroup do
|
|
|
138
137
|
|
|
139
138
|
describe "to_hash" do
|
|
140
139
|
before(:each) do
|
|
141
|
-
@field = Field.new
|
|
140
|
+
@field = DynamicFieldsets::Field.new
|
|
142
141
|
@field.stub!(:id).and_return 100
|
|
143
142
|
|
|
144
|
-
@fieldset_child1 = FieldsetChild.new
|
|
143
|
+
@fieldset_child1 = DynamicFieldsets::FieldsetChild.new
|
|
145
144
|
@fieldset_child1.stub!(:id).and_return 100
|
|
146
|
-
@fieldset_child2 = FieldsetChild.new
|
|
145
|
+
@fieldset_child2 = DynamicFieldsets::FieldsetChild.new
|
|
147
146
|
@fieldset_child2.stub!(:id).and_return 200
|
|
148
147
|
|
|
149
|
-
@dependency = Dependency.new
|
|
148
|
+
@dependency = DynamicFieldsets::Dependency.new
|
|
150
149
|
@dependency.stub!(:id).and_return 100
|
|
151
150
|
@dependency.stub!(:fieldset_child_id).and_return @fieldset_child1.id
|
|
152
151
|
@dependency.stub!(:relationship).and_return "equals"
|
|
153
152
|
@dependency.stub!(:value).and_return 5
|
|
154
153
|
|
|
155
|
-
@clause = DependencyClause.new
|
|
154
|
+
@clause = DynamicFieldsets::DependencyClause.new
|
|
156
155
|
@clause.stub!(:id).and_return 100
|
|
157
156
|
|
|
158
|
-
@group = DependencyGroup.new
|
|
157
|
+
@group = DynamicFieldsets::DependencyGroup.new
|
|
159
158
|
@group.stub!(:id).and_return 100
|
|
160
159
|
@group.stub!(:fieldset_child_id).and_return @fieldset_child2.id
|
|
161
160
|
@group.stub!(:action).and_return "show"
|
|
@@ -195,10 +194,10 @@ describe DependencyGroup do
|
|
|
195
194
|
end
|
|
196
195
|
|
|
197
196
|
it "should have a specific return structure even with a greater complexity" do
|
|
198
|
-
fieldset_child3 = FieldsetChild.new
|
|
197
|
+
fieldset_child3 = DynamicFieldsets::FieldsetChild.new
|
|
199
198
|
fieldset_child3.stub!(:id).and_return 300
|
|
200
199
|
|
|
201
|
-
dependency2 = Dependency.new
|
|
200
|
+
dependency2 = DynamicFieldsets::Dependency.new
|
|
202
201
|
dependency2.stub!(:id).and_return 200
|
|
203
202
|
dependency2.stub!(:relationship).and_return "equals"
|
|
204
203
|
dependency2.stub!(:value).and_return 5
|
|
@@ -231,7 +230,5 @@ describe DependencyGroup do
|
|
|
231
230
|
|
|
232
231
|
@group.to_hash.should == expected_result
|
|
233
232
|
end
|
|
234
|
-
|
|
235
233
|
end
|
|
236
|
-
|
|
237
234
|
end
|
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
|
-
include DynamicFieldsets
|
|
3
2
|
|
|
4
|
-
describe Dependency do
|
|
3
|
+
describe DynamicFieldsets::Dependency do
|
|
5
4
|
include DependencyHelper
|
|
6
5
|
|
|
7
6
|
it "should respond to fieldset_child" do
|
|
8
|
-
Dependency.new.should respond_to :fieldset_child
|
|
7
|
+
DynamicFieldsets::Dependency.new.should respond_to :fieldset_child
|
|
9
8
|
end
|
|
10
9
|
|
|
11
10
|
it "should respond to dependency_clause" do
|
|
12
|
-
Dependency.new.should respond_to :dependency_clause
|
|
11
|
+
DynamicFieldsets::Dependency.new.should respond_to :dependency_clause
|
|
13
12
|
end
|
|
14
13
|
|
|
15
14
|
describe "validations" do
|
|
16
15
|
|
|
17
16
|
before(:each) do
|
|
18
|
-
@dependency = Dependency.new
|
|
17
|
+
@dependency = DynamicFieldsets::Dependency.new
|
|
19
18
|
end
|
|
20
19
|
|
|
21
20
|
it "should be valid" do
|
|
@@ -45,9 +44,9 @@ describe Dependency do
|
|
|
45
44
|
|
|
46
45
|
describe "evaluate" do
|
|
47
46
|
before(:each) do
|
|
48
|
-
@fieldset_child = FieldsetChild.new
|
|
47
|
+
@fieldset_child = DynamicFieldsets::FieldsetChild.new
|
|
49
48
|
@fieldset_child.stub!(:id).and_return(100)
|
|
50
|
-
@dependency = Dependency.new
|
|
49
|
+
@dependency = DynamicFieldsets::Dependency.new
|
|
51
50
|
@dependency.attributes = valid_attributes
|
|
52
51
|
@input_hash = {100 => "test value"}
|
|
53
52
|
end
|
|
@@ -75,7 +74,7 @@ describe Dependency do
|
|
|
75
74
|
|
|
76
75
|
describe "relationship_list" do
|
|
77
76
|
it "should return an array" do
|
|
78
|
-
@dependency = Dependency.new
|
|
77
|
+
@dependency = DynamicFieldsets::Dependency.new
|
|
79
78
|
@dependency.attributes = valid_attributes
|
|
80
79
|
@dependency.relationship_list.should be_an_instance_of Array
|
|
81
80
|
end
|
|
@@ -83,7 +82,7 @@ describe Dependency do
|
|
|
83
82
|
|
|
84
83
|
describe "process_relationship" do
|
|
85
84
|
before(:each) do
|
|
86
|
-
@dependency = Dependency.new
|
|
85
|
+
@dependency = DynamicFieldsets::Dependency.new
|
|
87
86
|
@dependency.attributes = valid_attributes
|
|
88
87
|
@dependency.value = "test string"
|
|
89
88
|
end
|