rules_engine 0.1.4 → 0.1.5
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/VERSION +1 -1
- data/lib/rules_engine/rule/definition.rb +5 -2
- data/rails_generators/manifests/complex.rb +2 -5
- data/rails_generators/manifests/complex.yml +2 -5
- data/rails_generators/manifests/simple.yml +1 -1
- data/rails_generators/templates/app/controllers/re_plans_controller.rb +1 -1
- data/rails_generators/templates/app/controllers/re_workflow_rules_controller.rb +1 -3
- data/rails_generators/templates/app/models/re_rule.rb +13 -9
- data/rails_generators/templates/app/models/re_rule_expected_outcome.rb +2 -0
- data/rails_generators/templates/app/rules/complex.rb +4 -4
- data/rails_generators/templates/app/rules/simple.rb +8 -8
- data/rails_generators/templates/app/views/re_rule_definitions/complex/_edit.html.erb +1 -7
- data/rails_generators/templates/app/views/re_rule_definitions/complex/_form.html.erb +76 -0
- data/rails_generators/templates/app/views/re_rule_definitions/complex/{_word.html.erb → _form_word.html.erb} +0 -0
- data/rails_generators/templates/app/views/re_rule_definitions/complex/_help.html.erb +1 -1
- data/rails_generators/templates/app/views/re_rule_definitions/complex/_new.html.erb +1 -7
- data/rails_generators/templates/app/views/re_rule_definitions/simple/_edit.html.erb +1 -1
- data/rails_generators/templates/app/views/re_rule_definitions/simple/_form.html.erb +16 -7
- data/rails_generators/templates/app/views/re_rule_definitions/simple/_help.html.erb +1 -1
- data/rails_generators/templates/app/views/re_rule_definitions/simple/_new.html.erb +1 -1
- data/rails_generators/templates/app/views/re_workflows/_rule_change.html.erb +3 -3
- data/rails_generators/templates/app/views/re_workflows/_rule_show.html.erb +3 -3
- data/rails_generators/templates/doc/README.rules_engine +1 -1
- data/rails_generators/templates/spec/controllers/re_plans_controller_spec.rb +259 -183
- data/rails_generators/templates/spec/lib/rules/complex_spec.rb +67 -13
- data/rails_generators/templates/spec/lib/rules/simple_spec.rb +104 -54
- data/rails_generators/templates/spec/models/re_plan_spec.rb +1 -1
- data/rails_generators/templates/spec/models/re_rule_spec.rb +23 -18
- data/rails_generators/templates/spec/models/re_workflow_spec.rb +1 -1
- data/rails_generators/templates/spec/support/rules_engine_blueprints.rb +9 -1
- data/spec/railsenv/log/debug.log +592 -0
- data/spec/railsenv/log/test.log +52 -0
- data/spec/rules_engine/discovery_spec.rb +0 -1
- data/spec/rules_engine/rule/definition_spec.rb +8 -4
- metadata +6 -9
- data/rails_generators/templates/app/views/re_rule_definitions/complex/_script.html.erb +0 -25
- data/rails_generators/templates/app/views/re_rule_definitions/complex/_title.html.erb +0 -7
- data/rails_generators/templates/app/views/re_rule_definitions/complex/_words.html.erb +0 -16
- data/rails_generators/templates/app/views/re_rule_definitions/complex/_workflow.html.erb +0 -22
@@ -1,10 +1,14 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
2
|
|
3
|
+
def valid_<%=rule_name%>_rule_data
|
4
|
+
'["Rule Title", ["word one", "word two"], "start_workflow", "Other Workflow"]'
|
5
|
+
end
|
6
|
+
|
3
7
|
describe RulesEngine::Rule::<%=rule_class%> do
|
4
8
|
|
5
9
|
def valid_attributes
|
6
10
|
{
|
7
|
-
:<%=rule_name%>_title => '
|
11
|
+
:<%=rule_name%>_title => 'Another Title',
|
8
12
|
:<%=rule_name%>_words => {
|
9
13
|
"1" => { "word" => 'first word' },
|
10
14
|
"2" => { "word" => 'second word' }
|
@@ -12,10 +16,6 @@ describe RulesEngine::Rule::<%=rule_class%> do
|
|
12
16
|
}
|
13
17
|
end
|
14
18
|
|
15
|
-
def valid_json_data
|
16
|
-
'["Rule Title", ["one", "two"], "start_workflow", "Other Pipeline"]'
|
17
|
-
end
|
18
|
-
|
19
19
|
it "should be discoverable" do
|
20
20
|
RulesEngine::Discovery.rule_class("RulesEngine::Rule::<%=rule_class%>").should == RulesEngine::Rule::<%=rule_class%>
|
21
21
|
end
|
@@ -45,7 +45,7 @@ describe RulesEngine::Rule::<%=rule_class%> do
|
|
45
45
|
describe "setting the rule data" do
|
46
46
|
before(:each) do
|
47
47
|
@<%=rule_name%> = RulesEngine::Rule::<%=rule_class%>.new
|
48
|
-
@<%=rule_name%>.data =
|
48
|
+
@<%=rule_name%>.data = valid_<%=rule_name%>_rule_data
|
49
49
|
end
|
50
50
|
|
51
51
|
describe "the json data is valid" do
|
@@ -58,7 +58,7 @@ describe RulesEngine::Rule::<%=rule_class%> do
|
|
58
58
|
end
|
59
59
|
|
60
60
|
it "should set the words" do
|
61
|
-
@<%=rule_name%>.words.should == ["one", "two"]
|
61
|
+
@<%=rule_name%>.words.should == ["word one", "word two"]
|
62
62
|
end
|
63
63
|
|
64
64
|
it "should set the workflow_action" do
|
@@ -66,7 +66,7 @@ describe RulesEngine::Rule::<%=rule_class%> do
|
|
66
66
|
end
|
67
67
|
|
68
68
|
it "should set the workflow" do
|
69
|
-
@<%=rule_name%>.workflow.should == "Other
|
69
|
+
@<%=rule_name%>.workflow.should == "Other Workflow"
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
@@ -114,11 +114,11 @@ describe RulesEngine::Rule::<%=rule_class%> do
|
|
114
114
|
describe "the data" do
|
115
115
|
it "should be converted to a json string" do
|
116
116
|
<%=rule_name%> = RulesEngine::Rule::<%=rule_class%>.new
|
117
|
-
<%=rule_name%>.should_receive(:title).and_return(
|
117
|
+
<%=rule_name%>.should_receive(:title).and_return("mock title")
|
118
118
|
<%=rule_name%>.should_receive(:words).and_return(["one", "two"])
|
119
|
-
<%=rule_name%>.should_receive(:workflow_action).and_return(
|
120
|
-
<%=rule_name%>.should_receive(:workflow).and_return(
|
121
|
-
<%=rule_name%>.data.should == '[
|
119
|
+
<%=rule_name%>.should_receive(:workflow_action).and_return("workflow action")
|
120
|
+
<%=rule_name%>.should_receive(:workflow).and_return("workflow")
|
121
|
+
<%=rule_name%>.data.should == '["mock title",["one","two"],"workflow action","workflow"]'
|
122
122
|
end
|
123
123
|
end
|
124
124
|
|
@@ -169,7 +169,7 @@ describe RulesEngine::Rule::<%=rule_class%> do
|
|
169
169
|
describe "setting the <%=rule_name%>_title" do
|
170
170
|
it "should set the title" do
|
171
171
|
@<%=rule_name%>.attributes = valid_attributes
|
172
|
-
@<%=rule_name%>.title.should == '
|
172
|
+
@<%=rule_name%>.title.should == 'Another Title'
|
173
173
|
end
|
174
174
|
|
175
175
|
it "should not be valid if the '<%=rule_name%>_title' attribute is missing" do
|
@@ -329,3 +329,57 @@ describe RulesEngine::Rule::<%=rule_class%> do
|
|
329
329
|
end
|
330
330
|
end
|
331
331
|
end
|
332
|
+
|
333
|
+
describe ReWorkflowRulesController, :type => :controller do
|
334
|
+
integrate_views
|
335
|
+
|
336
|
+
before(:each) do
|
337
|
+
controller.instance_eval { flash.stub!(:sweep) }
|
338
|
+
|
339
|
+
RulesEngine::Discovery.discover!
|
340
|
+
|
341
|
+
controller.stub!(:rules_engine_reader_access_required).and_return(true)
|
342
|
+
controller.stub!(:rules_engine_editor_access_required).and_return(true)
|
343
|
+
|
344
|
+
@re_workflow = ReWorkflow.make
|
345
|
+
ReWorkflow.stub!(:find).and_return(@re_workflow)
|
346
|
+
end
|
347
|
+
|
348
|
+
describe "<%=rule_name%> rule help" do
|
349
|
+
it "should assign the <%=rule_name%> rule class" do
|
350
|
+
get :help, :rule_class_name => "RulesEngine::Rule::<%=rule_class%>"
|
351
|
+
assigns[:rule_class].should == RulesEngine::Rule::<%=rule_class%>
|
352
|
+
end
|
353
|
+
end
|
354
|
+
|
355
|
+
describe "new" do
|
356
|
+
it "show the new form" do
|
357
|
+
get :new, :rule_class_name => "RulesEngine::Rule::<%=rule_class%>"
|
358
|
+
response.should have_tag("form#re_rule_new_form") do
|
359
|
+
with_tag("input#<%=rule_name%>_title")
|
360
|
+
with_tag("input#<%=rule_name%>_words_0_word")
|
361
|
+
with_tag("select#<%=rule_name%>_workflow_action")
|
362
|
+
with_tag("input#<%=rule_name%>_workflow")
|
363
|
+
end
|
364
|
+
end
|
365
|
+
end
|
366
|
+
|
367
|
+
describe "edit" do
|
368
|
+
it "show the edit form" do
|
369
|
+
re_rule = ReRule.make(:re_workflow_id => @re_workflow.id,
|
370
|
+
:rule_class_name => "RulesEngine::Rule::<%=rule_class%>",
|
371
|
+
:data => valid_<%=rule_name%>_rule_data)
|
372
|
+
ReRule.stub!(:find).and_return(re_rule)
|
373
|
+
|
374
|
+
get :edit, :re_workflow_id => @re_workflow.id, :re_rule_id => 1001, :rule_class_name => "RulesEngine::Rule::<%=rule_class%>"
|
375
|
+
response.should have_tag("form#re_rule_edit_form") do
|
376
|
+
with_tag("input#<%=rule_name%>_title", :value => 'Rule Title')
|
377
|
+
with_tag("input#<%=rule_name%>_words_0_word", :value => 'word one')
|
378
|
+
with_tag("input#<%=rule_name%>_words_1_word", :value => 'word two')
|
379
|
+
with_tag("select#<%=rule_name%>_workflow_action", :value => 'start_workflow')
|
380
|
+
with_tag("input#<%=rule_name%>_workflow", :value => 'Other Workflow')
|
381
|
+
end
|
382
|
+
end
|
383
|
+
end
|
384
|
+
|
385
|
+
end
|
@@ -1,18 +1,18 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
2
|
|
3
|
+
def valid_<%=rule_name%>_rule_data
|
4
|
+
'["Rule Title", "Rule Description"]'
|
5
|
+
end
|
6
|
+
|
3
7
|
describe RulesEngine::Rule::Simple do
|
4
8
|
|
5
9
|
def valid_attributes
|
6
10
|
{
|
7
|
-
|
8
|
-
|
11
|
+
:<%=rule_name%>_title => 'Rule Title',
|
12
|
+
:<%=rule_name%>_description => 'Rule Description'
|
9
13
|
}
|
10
14
|
end
|
11
15
|
|
12
|
-
def valid_json_data
|
13
|
-
'["Valid Title", "Valid Description"]'
|
14
|
-
end
|
15
|
-
|
16
16
|
it "should be discoverable" do
|
17
17
|
RulesEngine::Discovery.rule_class("RulesEngine::Rule::Simple").should == RulesEngine::Rule::Simple
|
18
18
|
end
|
@@ -26,50 +26,50 @@ describe RulesEngine::Rule::Simple do
|
|
26
26
|
RulesEngine::Rule::Simple.options[:display_name].should == "Simple"
|
27
27
|
end
|
28
28
|
|
29
|
-
it "should have the help template of '/re_rule_definitions
|
30
|
-
RulesEngine::Rule::Simple.options[:help_partial].should == '/re_rule_definitions
|
29
|
+
it "should have the help template of '/re_rule_definitions/<%=rule_name%>/help'" do
|
30
|
+
RulesEngine::Rule::Simple.options[:help_partial].should == '/re_rule_definitions/<%=rule_name%>/help'
|
31
31
|
end
|
32
32
|
|
33
|
-
it "should have the new template of '/re_rule_definitions
|
34
|
-
RulesEngine::Rule::Simple.options[:new_partial].should == '/re_rule_definitions
|
33
|
+
it "should have the new template of '/re_rule_definitions/<%=rule_name%>/new'" do
|
34
|
+
RulesEngine::Rule::Simple.options[:new_partial].should == '/re_rule_definitions/<%=rule_name%>/new'
|
35
35
|
end
|
36
36
|
|
37
|
-
it "should have the edit view partial template of '/re_rule_definitions
|
38
|
-
RulesEngine::Rule::Simple.options[:edit_partial].should == '/re_rule_definitions
|
37
|
+
it "should have the edit view partial template of '/re_rule_definitions/<%=rule_name%>/edit'" do
|
38
|
+
RulesEngine::Rule::Simple.options[:edit_partial].should == '/re_rule_definitions/<%=rule_name%>/edit'
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
42
|
describe "setting the rule data" do
|
43
43
|
before(:each) do
|
44
|
-
|
45
|
-
|
44
|
+
@<%=rule_name%> = RulesEngine::Rule::Simple.new
|
45
|
+
@<%=rule_name%>.data = valid_<%=rule_name%>_rule_data
|
46
46
|
end
|
47
47
|
|
48
48
|
describe "the data is valid" do
|
49
49
|
it "should be valid" do
|
50
|
-
|
50
|
+
@<%=rule_name%>.should be_valid
|
51
51
|
end
|
52
52
|
|
53
53
|
it "should set the title" do
|
54
|
-
|
54
|
+
@<%=rule_name%>.title.should == "Rule Title"
|
55
55
|
end
|
56
56
|
|
57
57
|
it "should set the description" do
|
58
|
-
|
58
|
+
@<%=rule_name%>.description.should == "Rule Description"
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
62
|
describe "the data is nil" do
|
63
63
|
it "should set the title to nil" do
|
64
|
-
|
65
|
-
|
66
|
-
|
64
|
+
@<%=rule_name%>.title.should_not be_nil
|
65
|
+
@<%=rule_name%>.data = nil
|
66
|
+
@<%=rule_name%>.title.should be_nil
|
67
67
|
end
|
68
68
|
|
69
69
|
it "should set the description to nil" do
|
70
|
-
|
71
|
-
|
72
|
-
|
70
|
+
@<%=rule_name%>.title.should_not be_nil
|
71
|
+
@<%=rule_name%>.data = nil
|
72
|
+
@<%=rule_name%>.description.should be_nil
|
73
73
|
end
|
74
74
|
end
|
75
75
|
end
|
@@ -77,69 +77,69 @@ describe RulesEngine::Rule::Simple do
|
|
77
77
|
describe "the summary" do
|
78
78
|
describe "description set" do
|
79
79
|
it "should be the rule description" do
|
80
|
-
|
81
|
-
|
82
|
-
|
80
|
+
<%=rule_name%> = RulesEngine::Rule::Simple.new
|
81
|
+
<%=rule_name%>.should_receive(:description).and_return("mock description")
|
82
|
+
<%=rule_name%>.summary.should == "mock description"
|
83
83
|
end
|
84
84
|
end
|
85
85
|
describe "description not set" do
|
86
86
|
it "should be Does Nothing" do
|
87
|
-
|
88
|
-
|
89
|
-
|
87
|
+
<%=rule_name%> = RulesEngine::Rule::Simple.new
|
88
|
+
<%=rule_name%>.should_receive(:description).and_return(nil)
|
89
|
+
<%=rule_name%>.summary.should == "Does Nothing"
|
90
90
|
end
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
94
94
|
describe "the data" do
|
95
95
|
it "should be converted to a json string" do
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
96
|
+
<%=rule_name%> = RulesEngine::Rule::Simple.new
|
97
|
+
<%=rule_name%>.should_receive(:title).and_return("mock title")
|
98
|
+
<%=rule_name%>.should_receive(:description).and_return("mock description")
|
99
|
+
<%=rule_name%>.data.should == '["mock title","mock description"]'
|
100
100
|
end
|
101
101
|
end
|
102
102
|
|
103
103
|
describe "the expected_outcomes" do
|
104
104
|
it "should be outcome next" do
|
105
|
-
|
106
|
-
|
105
|
+
<%=rule_name%> = RulesEngine::Rule::Simple.new
|
106
|
+
<%=rule_name%>.expected_outcomes.should == [:outcome => RulesEngine::Rule::Outcome::NEXT]
|
107
107
|
end
|
108
108
|
end
|
109
109
|
|
110
110
|
describe "setting the rule attributes" do
|
111
111
|
before(:each) do
|
112
|
-
|
112
|
+
@<%=rule_name%> = RulesEngine::Rule::Simple.new
|
113
113
|
end
|
114
114
|
|
115
115
|
it "should be valid with valid attributes" do
|
116
|
-
|
117
|
-
|
116
|
+
@<%=rule_name%>.attributes = valid_attributes
|
117
|
+
@<%=rule_name%>.should be_valid
|
118
118
|
end
|
119
119
|
|
120
|
-
describe "setting the
|
120
|
+
describe "setting the <%=rule_name%>_title" do
|
121
121
|
it "should set the title" do
|
122
|
-
|
123
|
-
|
122
|
+
@<%=rule_name%>.attributes = valid_attributes
|
123
|
+
@<%=rule_name%>.title.should == 'Rule Title'
|
124
124
|
end
|
125
125
|
|
126
|
-
it "should not be valid if the '
|
127
|
-
|
128
|
-
|
129
|
-
|
126
|
+
it "should not be valid if the '<%=rule_name%>_title' attribute is missing" do
|
127
|
+
@<%=rule_name%>.attributes = valid_attributes.except(:<%=rule_name%>_title)
|
128
|
+
@<%=rule_name%>.should_not be_valid
|
129
|
+
@<%=rule_name%>.errors.should include(:<%=rule_name%>_title)
|
130
130
|
end
|
131
131
|
|
132
|
-
it "should not be valid if the '
|
133
|
-
|
134
|
-
|
135
|
-
|
132
|
+
it "should not be valid if the '<%=rule_name%>_title' attribute is blank" do
|
133
|
+
@<%=rule_name%>.attributes = valid_attributes.merge(:<%=rule_name%>_title => "")
|
134
|
+
@<%=rule_name%>.should_not be_valid
|
135
|
+
@<%=rule_name%>.errors.should include(:<%=rule_name%>_title)
|
136
136
|
end
|
137
137
|
end
|
138
138
|
|
139
|
-
describe "setting the
|
139
|
+
describe "setting the <%=rule_name%>_description" do
|
140
140
|
it "should set the description" do
|
141
|
-
|
142
|
-
|
141
|
+
@<%=rule_name%>.attributes = valid_attributes.merge(:<%=rule_name%>_description => 'Rule Description')
|
142
|
+
@<%=rule_name%>.description.should == 'Rule Description'
|
143
143
|
end
|
144
144
|
end
|
145
145
|
end
|
@@ -154,8 +154,58 @@ describe RulesEngine::Rule::Simple do
|
|
154
154
|
|
155
155
|
describe "processing the rule" do
|
156
156
|
it "should do nothing" do
|
157
|
-
|
158
|
-
|
157
|
+
@<%=rule_name%> = RulesEngine::Rule::Simple.new
|
158
|
+
@<%=rule_name%>.process(1001, {}).outcome.should == RulesEngine::Rule::Outcome::NEXT
|
159
159
|
end
|
160
160
|
end
|
161
161
|
end
|
162
|
+
|
163
|
+
|
164
|
+
describe ReWorkflowRulesController, :type => :controller do
|
165
|
+
integrate_views
|
166
|
+
|
167
|
+
before(:each) do
|
168
|
+
controller.instance_eval { flash.stub!(:sweep) }
|
169
|
+
|
170
|
+
RulesEngine::Discovery.discover!
|
171
|
+
|
172
|
+
controller.stub!(:rules_engine_reader_access_required).and_return(true)
|
173
|
+
controller.stub!(:rules_engine_editor_access_required).and_return(true)
|
174
|
+
|
175
|
+
@re_workflow = ReWorkflow.make
|
176
|
+
ReWorkflow.stub!(:find).and_return(@re_workflow)
|
177
|
+
end
|
178
|
+
|
179
|
+
describe "help" do
|
180
|
+
it "should assign the <%=rule_name%> rule class" do
|
181
|
+
get :help, :rule_class_name => "RulesEngine::Rule::Simple"
|
182
|
+
assigns[:rule_class].should == RulesEngine::Rule::Simple
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
describe "new" do
|
187
|
+
it "show the new form" do
|
188
|
+
get :new, :rule_class_name => "RulesEngine::Rule::Simple"
|
189
|
+
response.should have_tag("form#re_rule_new_form") do
|
190
|
+
with_tag("input#<%=rule_name%>_title")
|
191
|
+
with_tag("input#<%=rule_name%>_description")
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
describe "edit" do
|
197
|
+
it "show the edit form" do
|
198
|
+
re_rule = ReRule.make(:re_workflow_id => @re_workflow.id,
|
199
|
+
:rule_class_name => "RulesEngine::Rule::Simple",
|
200
|
+
:data => valid_<%=rule_name%>_rule_data)
|
201
|
+
ReRule.stub!(:find).and_return(re_rule)
|
202
|
+
|
203
|
+
get :edit, :re_workflow_id => @re_workflow.id, :re_rule_id => 1001, :rule_class_name => "RulesEngine::Rule::Simple"
|
204
|
+
response.should have_tag("form#re_rule_edit_form") do
|
205
|
+
with_tag("input#<%=rule_name%>_title", :value => 'Rule Title')
|
206
|
+
with_tag("input#<%=rule_name%>_description", :value => 'Rule Description')
|
207
|
+
end
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
end
|
@@ -4,7 +4,7 @@ describe ReRule do
|
|
4
4
|
def valid_attributes
|
5
5
|
{
|
6
6
|
:rule_class_name => "MockRuleClass",
|
7
|
-
:title => "
|
7
|
+
:title => "Rule Title",
|
8
8
|
:summary => "Mock Summary",
|
9
9
|
:data => '["Rule Title", ["one", "two"], "start_workflow", "Other Pipeline"]'
|
10
10
|
}
|
@@ -15,8 +15,9 @@ describe ReRule do
|
|
15
15
|
@rule.stub!(:title=)
|
16
16
|
@rule.stub!(:summary=)
|
17
17
|
@rule.stub!(:data=)
|
18
|
-
@rule.stub!(:
|
19
|
-
@rule.stub!(:
|
18
|
+
@rule.stub!(:before_create)
|
19
|
+
@rule.stub!(:before_update)
|
20
|
+
@rule.stub!(:before_destroy)
|
20
21
|
@rule.stub!(:expected_outcomes).and_return([])
|
21
22
|
@rule.stub!(:valid?).and_return(true)
|
22
23
|
@rule_class = mock("MockRuleClass")
|
@@ -153,31 +154,35 @@ describe ReRule do
|
|
153
154
|
end
|
154
155
|
end
|
155
156
|
|
156
|
-
describe "after
|
157
|
+
describe "after creating a re_rule" do
|
157
158
|
it "should notify the rule" do
|
158
159
|
re_rule = ReRule.new(valid_attributes)
|
159
160
|
re_rule.stub!(:re_workflow).and_return(@re_workflow)
|
160
161
|
|
161
|
-
@
|
162
|
-
re_rule.
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
162
|
+
@rule.should_receive(:before_create)
|
163
|
+
re_rule.save
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
describe "after updating a re_rule" do
|
168
|
+
it "should notify the rule" do
|
169
|
+
re_rule = ReRule.new(valid_attributes)
|
170
|
+
re_rule.stub!(:re_workflow).and_return(@re_workflow)
|
171
|
+
re_rule.save
|
172
|
+
|
173
|
+
re_rule.title = "New Title"
|
174
|
+
@rule.should_receive(:before_update)
|
168
175
|
re_rule.save
|
169
|
-
updated_code.should == '1001'
|
170
176
|
end
|
171
177
|
end
|
172
178
|
|
173
179
|
describe "before destroying a re_rule" do
|
174
180
|
it "should notify the rule" do
|
175
|
-
|
176
|
-
|
177
|
-
@re_rule.stub!(:re_workflow).and_return(@re_workflow)
|
181
|
+
re_rule = ReRule.new(valid_attributes)
|
182
|
+
re_rule.stub!(:re_workflow).and_return(@re_workflow)
|
178
183
|
|
179
|
-
@rule.should_receive(:
|
180
|
-
|
184
|
+
@rule.should_receive(:before_destroy)
|
185
|
+
re_rule.destroy
|
181
186
|
end
|
182
187
|
end
|
183
188
|
|
@@ -263,7 +268,7 @@ describe ReRule do
|
|
263
268
|
|
264
269
|
describe "moving items in a list" do
|
265
270
|
it "should move a rule down in the list" do
|
266
|
-
re_workflow = ReWorkflow.create!(:code => "AA-MOCK",:title => "
|
271
|
+
re_workflow = ReWorkflow.create!(:code => "AA-MOCK",:title => "Rule Title")
|
267
272
|
|
268
273
|
re_rule_1 = ReRule.new(valid_attributes)
|
269
274
|
re_rule_2 = ReRule.new(valid_attributes)
|