rules_engine_templates 0.0.5 → 0.0.6
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/rails_generators/manifests/plan_start.rb +5 -5
- data/rails_generators/manifests/plan_start.yml +5 -5
- data/rails_generators/manifests/tweet_filter.rb +6 -6
- data/rails_generators/manifests/tweet_filter.yml +6 -6
- data/rails_generators/manifests/tweet_filter_rt.rb +5 -5
- data/rails_generators/manifests/tweet_filter_rt.yml +5 -5
- data/rails_generators/manifests/tweet_reader.rb +5 -5
- data/rails_generators/manifests/tweet_reader.yml +5 -5
- data/rails_generators/manifests/tweet_word_filter.rb +5 -5
- data/rails_generators/manifests/tweet_word_filter.yml +5 -5
- data/rails_generators/manifests/tweet_word_splitter.rb +5 -5
- data/rails_generators/manifests/tweet_word_splitter.yml +5 -5
- data/rails_generators/manifests/tweet_word_writer.rb +13 -7
- data/rails_generators/manifests/tweet_word_writer.yml +13 -7
- data/rails_generators/manifests/workflow_start.rb +5 -5
- data/rails_generators/manifests/workflow_start.yml +5 -5
- data/rails_generators/manifests/workflow_stop.rb +5 -5
- data/rails_generators/manifests/workflow_stop.yml +5 -5
- data/rails_generators/templates/app/controllers/rules/tweet_word_writer_controller.rb +12 -2
- data/rails_generators/templates/app/rules/plan_start.rb +14 -12
- data/rails_generators/templates/app/rules/tweet_filter.rb +15 -15
- data/rails_generators/templates/app/rules/tweet_filter_rt.rb +4 -4
- data/rails_generators/templates/app/rules/tweet_reader.rb +21 -23
- data/rails_generators/templates/app/rules/tweet_word_filter.rb +15 -15
- data/rails_generators/templates/app/rules/tweet_word_splitter.rb +4 -4
- data/rails_generators/templates/app/rules/tweet_word_writer.rb +36 -13
- data/rails_generators/templates/app/rules/workflow_start.rb +13 -13
- data/rails_generators/templates/app/rules/workflow_stop.rb +4 -4
- data/rails_generators/templates/app/views/re_rules/plan_start/_edit.html.erb +1 -0
- data/rails_generators/templates/app/views/{re_rule_definitions → re_rules}/plan_start/_form.html.erb +2 -2
- data/rails_generators/templates/app/views/{re_rule_definitions → re_rules}/plan_start/_help.html.erb +0 -0
- data/rails_generators/templates/app/views/re_rules/plan_start/_new.html.erb +1 -0
- data/rails_generators/templates/app/views/re_rules/tweet_filter/_edit.html.erb +1 -0
- data/rails_generators/templates/app/views/{re_rule_definitions → re_rules}/tweet_filter/_form.html.erb +4 -4
- data/rails_generators/templates/app/views/{re_rule_definitions → re_rules}/tweet_filter/_form_word.html.erb +2 -2
- data/rails_generators/templates/app/views/{re_rule_definitions → re_rules}/tweet_filter/_help.html.erb +0 -0
- data/rails_generators/templates/app/views/re_rules/tweet_filter/_new.html.erb +1 -0
- data/rails_generators/templates/app/views/re_rules/tweet_filter_rt/_edit.html.erb +1 -0
- data/rails_generators/templates/app/views/{re_rule_definitions → re_rules}/tweet_filter_rt/_form.html.erb +0 -0
- data/rails_generators/templates/app/views/{re_rule_definitions → re_rules}/tweet_filter_rt/_help.html.erb +0 -0
- data/rails_generators/templates/app/views/re_rules/tweet_filter_rt/_new.html.erb +1 -0
- data/rails_generators/templates/app/views/re_rules/tweet_reader/_edit.html.erb +1 -0
- data/rails_generators/templates/app/views/{re_rule_definitions → re_rules}/tweet_reader/_form.html.erb +6 -6
- data/rails_generators/templates/app/views/{re_rule_definitions → re_rules}/tweet_reader/_help.html.erb +0 -0
- data/rails_generators/templates/app/views/re_rules/tweet_reader/_new.html.erb +1 -0
- data/rails_generators/templates/app/views/re_rules/tweet_word_filter/_edit.html.erb +1 -0
- data/rails_generators/templates/app/views/{re_rule_definitions → re_rules}/tweet_word_filter/_form.html.erb +4 -4
- data/rails_generators/templates/app/views/{re_rule_definitions → re_rules}/tweet_word_filter/_help.html.erb +0 -0
- data/rails_generators/templates/app/views/re_rules/tweet_word_filter/_new.html.erb +1 -0
- data/rails_generators/templates/app/views/re_rules/tweet_word_splitter/_edit.html.erb +1 -0
- data/rails_generators/templates/app/views/{re_rule_definitions → re_rules}/tweet_word_splitter/_form.html.erb +0 -0
- data/rails_generators/templates/app/views/{re_rule_definitions → re_rules}/tweet_word_splitter/_help.html.erb +0 -0
- data/rails_generators/templates/app/views/re_rules/tweet_word_splitter/_new.html.erb +1 -0
- data/rails_generators/templates/app/views/re_rules/tweet_word_writer/_edit.html.erb +1 -0
- data/rails_generators/templates/app/views/{re_rule_definitions → re_rules}/tweet_word_writer/_form.html.erb +0 -0
- data/rails_generators/templates/app/views/{re_rule_definitions → re_rules}/tweet_word_writer/_help.html.erb +1 -1
- data/rails_generators/templates/app/views/re_rules/tweet_word_writer/_new.html.erb +1 -0
- data/rails_generators/templates/app/views/re_rules/tweet_word_writer/index.html.erb +45 -0
- data/rails_generators/templates/app/views/re_rules/workflow_start/_edit.html.erb +1 -0
- data/rails_generators/templates/app/views/{re_rule_definitions → re_rules}/workflow_start/_form.html.erb +2 -2
- data/rails_generators/templates/app/views/{re_rule_definitions → re_rules}/workflow_start/_help.html.erb +0 -0
- data/rails_generators/templates/app/views/re_rules/workflow_start/_new.html.erb +1 -0
- data/rails_generators/templates/app/views/re_rules/workflow_stop/_edit.html.erb +1 -0
- data/rails_generators/templates/app/views/{re_rule_definitions → re_rules}/workflow_stop/_form.html.erb +0 -0
- data/rails_generators/templates/app/views/{re_rule_definitions → re_rules}/workflow_stop/_help.html.erb +0 -0
- data/rails_generators/templates/app/views/re_rules/workflow_stop/_new.html.erb +1 -0
- data/rails_generators/templates/db/migrate/20100727235508_create_tweet_word_writer.rb +12 -4
- data/rails_generators/templates/spec/lib/rules/plan_start_spec.rb +35 -34
- data/rails_generators/templates/spec/lib/rules/tweet_filter_rt_spec.rb +10 -10
- data/rails_generators/templates/spec/lib/rules/tweet_filter_spec.rb +43 -43
- data/rails_generators/templates/spec/lib/rules/tweet_reader_spec.rb +77 -85
- data/rails_generators/templates/spec/lib/rules/tweet_word_filter_spec.rb +37 -46
- data/rails_generators/templates/spec/lib/rules/tweet_word_splitter_spec.rb +16 -16
- data/rails_generators/templates/spec/lib/rules/tweet_word_writer_spec.rb +98 -33
- data/rails_generators/templates/spec/lib/rules/workflow_start_spec.rb +22 -22
- data/rails_generators/templates/spec/lib/rules/workflow_stop_spec.rb +7 -7
- metadata +42 -43
- data/rails_generators/templates/app/views/re_rule_definitions/plan_start/_edit.html.erb +0 -1
- data/rails_generators/templates/app/views/re_rule_definitions/plan_start/_new.html.erb +0 -1
- data/rails_generators/templates/app/views/re_rule_definitions/tweet_filter/_edit.html.erb +0 -1
- data/rails_generators/templates/app/views/re_rule_definitions/tweet_filter/_new.html.erb +0 -1
- data/rails_generators/templates/app/views/re_rule_definitions/tweet_filter_rt/_edit.html.erb +0 -1
- data/rails_generators/templates/app/views/re_rule_definitions/tweet_filter_rt/_new.html.erb +0 -1
- data/rails_generators/templates/app/views/re_rule_definitions/tweet_reader/_edit.html.erb +0 -1
- data/rails_generators/templates/app/views/re_rule_definitions/tweet_reader/_new.html.erb +0 -1
- data/rails_generators/templates/app/views/re_rule_definitions/tweet_word_filter/_edit.html.erb +0 -1
- data/rails_generators/templates/app/views/re_rule_definitions/tweet_word_filter/_new.html.erb +0 -1
- data/rails_generators/templates/app/views/re_rule_definitions/tweet_word_splitter/_edit.html.erb +0 -1
- data/rails_generators/templates/app/views/re_rule_definitions/tweet_word_splitter/_new.html.erb +0 -1
- data/rails_generators/templates/app/views/re_rule_definitions/tweet_word_writer/_edit.html.erb +0 -1
- data/rails_generators/templates/app/views/re_rule_definitions/tweet_word_writer/_new.html.erb +0 -1
- data/rails_generators/templates/app/views/re_rule_definitions/tweet_word_writer/index.html.erb +0 -16
- data/rails_generators/templates/app/views/re_rule_definitions/workflow_start/_edit.html.erb +0 -1
- data/rails_generators/templates/app/views/re_rule_definitions/workflow_start/_new.html.erb +0 -1
- data/rails_generators/templates/app/views/re_rule_definitions/workflow_stop/_edit.html.erb +0 -1
- data/rails_generators/templates/app/views/re_rule_definitions/workflow_stop/_new.html.erb +0 -1
- data/rails_generators/templates/spec/lib/rules/rule_tweet_filter_spec.rb +0 -220
|
@@ -14,16 +14,16 @@
|
|
|
14
14
|
:error => @re_rule.rule.errors[:<%=rule_name%>_title],
|
|
15
15
|
:span => '4x13' %>
|
|
16
16
|
|
|
17
|
-
<%%= re_text_field "Message",
|
|
18
|
-
"<%=rule_name%>
|
|
19
|
-
params[:<%=rule_name%>
|
|
17
|
+
<%%= re_text_field "Twitter Message",
|
|
18
|
+
"<%=rule_name%>_twitter_message",
|
|
19
|
+
params[:<%=rule_name%>_twitter_message] || @re_rule.rule.twitter_message,
|
|
20
20
|
:size => 40,
|
|
21
21
|
:required => true,
|
|
22
|
-
:error => @re_rule.rule.errors[:<%=rule_name%>
|
|
22
|
+
:error => @re_rule.rule.errors[:<%=rule_name%>_twitter_message],
|
|
23
23
|
:span => '4x13' %>
|
|
24
24
|
|
|
25
|
-
<%%= re_text_field "
|
|
25
|
+
<%%= re_text_field "Process with Workflow", "<%=rule_name%>_workflow_code", @re_rule.rule.workflow_code || params[:<%=rule_name%>_workflow_code],
|
|
26
26
|
:size => 20,
|
|
27
27
|
:required => true,
|
|
28
28
|
:span => '4x13',
|
|
29
|
-
:error => @re_rule.rule.errors[:<%=rule_name%>
|
|
29
|
+
:error => @re_rule.rule.errors[:<%=rule_name%>_workflow_code] %>
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<%%= render '/re_rules/<%=rule_name%>/form' %>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<%%= render '/re_rules/<%=rule_name%>/form', :f => f %>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<%% javascript_tag do %>
|
|
2
|
-
var new_<%=rule_name%> = '<%%=escape_javascript(render("/
|
|
2
|
+
var new_<%=rule_name%> = '<%%=escape_javascript(render("/re_rules/<%=rule_name%>/form_word"))%>'
|
|
3
3
|
|
|
4
4
|
$(document).ready(function() {
|
|
5
5
|
$('#<%=rule_name%>_title').focus();
|
|
@@ -17,15 +17,15 @@
|
|
|
17
17
|
:span => '4x13' %>
|
|
18
18
|
|
|
19
19
|
<%% position = 0 %>
|
|
20
|
-
<%% (@re_rule.rule.
|
|
20
|
+
<%% (@re_rule.rule.match_words || []).each do | word | %>
|
|
21
21
|
<%% f.fields_for :rule_data, {:first => false} do |frd| %>
|
|
22
|
-
<%%= render '/
|
|
22
|
+
<%%= render '/re_rules/<%=rule_name%>/form_word', :f => frd, :position => position, :word => word %>
|
|
23
23
|
<%% position += 1 %>
|
|
24
24
|
<%% end %>
|
|
25
25
|
<%% end %>
|
|
26
26
|
<%% if position == 0 %>
|
|
27
27
|
<%% f.fields_for :rule_data, {:first => false} do |frd| %>
|
|
28
|
-
<%%= render '/
|
|
28
|
+
<%%= render '/re_rules/<%=rule_name%>/form_word', :f => frd, :position => position %>
|
|
29
29
|
<%% end %>
|
|
30
30
|
<%% end %>
|
|
31
31
|
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<%%= render '/re_rules/<%=rule_name%>/form', :f => f %>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<%%= render '/re_rules/<%=rule_name%>/form' %>
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<%%= render '/re_rules/<%=rule_name%>/form' %>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<%%= render '/re_rules/<%=rule_name%>/form' %>
|
|
File without changes
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
<p>Write the twitter words to the database and map the progress</p>
|
|
2
|
-
<%%= link_to("List Tweet Words", <%=rule_name%>
|
|
2
|
+
<%%= link_to("List Tweet Words", <%=rule_name%>_index_path) %>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<%%= render '/re_rules/<%=rule_name%>/form' %>
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<%% set_re_breadcrumbs '<span class="re-bc-publication-show">Twitter Words</span>' %>
|
|
2
|
+
<%% if rules_engine_editor? %>
|
|
3
|
+
<%% javascript_tag do %>
|
|
4
|
+
|
|
5
|
+
$(document).ready(function() {
|
|
6
|
+
$('.<%=rule_name%>_ignore').live('click', function() {
|
|
7
|
+
var word_id = $(this).attr('href').replace('#', '');
|
|
8
|
+
|
|
9
|
+
if (confirm("Remove Word : " + $.trim($('#<%=rule_name%>_title_' + word_id).html()))) {
|
|
10
|
+
$('#<%=rule_name%>_word_id').attr('value', word_id);
|
|
11
|
+
$('#<%=rule_name%>_form').submit();
|
|
12
|
+
}
|
|
13
|
+
return false;
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
<%% end %>
|
|
18
|
+
<%% end %>
|
|
19
|
+
|
|
20
|
+
<div class="hide">
|
|
21
|
+
<%% form_for(:<%=rule_name%>, :url => <%=rule_name%>_index_path, :html => {:method => :put, :id => "<%=rule_name%>_form"}) do |f| %>
|
|
22
|
+
<%%= f.text_field(:word_id) %>
|
|
23
|
+
<%% end %>
|
|
24
|
+
</div>
|
|
25
|
+
|
|
26
|
+
<div class="prepend-1 span-22 append-1">
|
|
27
|
+
<%% if @re_tweet_words.empty? %>
|
|
28
|
+
<p class="red">No Tweet Words Stored</p>
|
|
29
|
+
<%% end %>
|
|
30
|
+
<%% @re_tweet_words.each do |re_tweet_word| %>
|
|
31
|
+
<p class="span-1">
|
|
32
|
+
<%%=h re_tweet_word.word_count %>
|
|
33
|
+
</p>
|
|
34
|
+
<p class="span-19" id="<%=rule_name%>_title_<%%= re_tweet_word.word.id %>">
|
|
35
|
+
<%%=h re_tweet_word.word.word %>
|
|
36
|
+
</p>
|
|
37
|
+
<p class="span-1 last smalltext">
|
|
38
|
+
<%% if rules_engine_editor? %>
|
|
39
|
+
<%%= link_to("ignore", "##{re_tweet_word.word.id}", :class => "red <%=rule_name%>_ignore") %>
|
|
40
|
+
<%% end %>
|
|
41
|
+
</p>
|
|
42
|
+
<hr/>
|
|
43
|
+
<%% end %>
|
|
44
|
+
|
|
45
|
+
</div>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<%%= render '/re_rules/<%=rule_name%>/form' %>
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
:error => @re_rule.rule.errors[:<%=rule_name%>_title],
|
|
15
15
|
:span => '4x13' %>
|
|
16
16
|
|
|
17
|
-
<%%= re_text_field "Workflow Code", "<%=rule_name%>
|
|
17
|
+
<%%= re_text_field "Workflow Code", "<%=rule_name%>_workflow_code", @re_rule.rule.workflow_code || params[:<%=rule_name%>_workflow_code],
|
|
18
18
|
:size => 20,
|
|
19
19
|
:required => true,
|
|
20
20
|
:span => '4x13',
|
|
21
|
-
:error => @re_rule.rule.errors[:<%=rule_name%>
|
|
21
|
+
:error => @re_rule.rule.errors[:<%=rule_name%>_workflow_code] %>
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<%%= render '/re_rules/<%=rule_name%>/form' %>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<%%= render '/re_rules/<%=rule_name%>/form' %>
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<%%= render '/re_rules/<%=rule_name%>/form' %>
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
class Create<%=rule_class%> < ActiveRecord::Migration
|
|
2
2
|
def self.up
|
|
3
|
-
create_table :re_<%=rule_name%>
|
|
4
|
-
t.string
|
|
3
|
+
create_table :re_<%=rule_name%> do |t|
|
|
4
|
+
t.string :title
|
|
5
5
|
end
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
create_table :re_<%=rule_name%>_words do |t|
|
|
8
|
+
t.integer :writer_id
|
|
9
|
+
t.string :word
|
|
10
|
+
t.integer :ignore_word
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
add_index :re_<%=rule_name%>_words, [:writer_id]
|
|
14
|
+
add_index :re_<%=rule_name%>_words, [:writer_id, :word]
|
|
8
15
|
|
|
9
16
|
create_table :re_<%=rule_name%>_count do |t|
|
|
10
17
|
t.integer :word_id
|
|
@@ -18,7 +25,8 @@ class Create<%=rule_class%> < ActiveRecord::Migration
|
|
|
18
25
|
end
|
|
19
26
|
|
|
20
27
|
def self.down
|
|
21
|
-
drop_table :re_<%=rule_name%>
|
|
28
|
+
drop_table :re_<%=rule_name%>
|
|
29
|
+
drop_table :re_<%=rule_name%>_words
|
|
22
30
|
drop_table :re_<%=rule_name%>_count
|
|
23
31
|
end
|
|
24
32
|
end
|
|
@@ -10,7 +10,7 @@ describe RulesEngine::Rule::<%=rule_class%> do
|
|
|
10
10
|
def valid_attributes
|
|
11
11
|
{
|
|
12
12
|
:<%=rule_name%>_title => 'Rule Title',
|
|
13
|
-
:<%=rule_name%>
|
|
13
|
+
:<%=rule_name%>_plan_code => 'Next Plan'
|
|
14
14
|
}
|
|
15
15
|
end
|
|
16
16
|
|
|
@@ -27,16 +27,16 @@ describe RulesEngine::Rule::<%=rule_class%> do
|
|
|
27
27
|
RulesEngine::Rule::<%=rule_class%>.options[:display_name].should == "Plan Start"
|
|
28
28
|
end
|
|
29
29
|
|
|
30
|
-
it "should have the help template of '/
|
|
31
|
-
RulesEngine::Rule::<%=rule_class%>.options[:help_partial].should == '/
|
|
30
|
+
it "should have the help template of '/re_rules/<%=rule_name%>/help'" do
|
|
31
|
+
RulesEngine::Rule::<%=rule_class%>.options[:help_partial].should == '/re_rules/<%=rule_name%>/help'
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
-
it "should have the new template of '/
|
|
35
|
-
RulesEngine::Rule::<%=rule_class%>.options[:new_partial].should == '/
|
|
34
|
+
it "should have the new template of '/re_rules/<%=rule_name%>/new'" do
|
|
35
|
+
RulesEngine::Rule::<%=rule_class%>.options[:new_partial].should == '/re_rules/<%=rule_name%>/new'
|
|
36
36
|
end
|
|
37
37
|
|
|
38
|
-
it "should have the edit view partial template of '/
|
|
39
|
-
RulesEngine::Rule::<%=rule_class%>.options[:edit_partial].should == '/
|
|
38
|
+
it "should have the edit view partial template of '/re_rules/<%=rule_name%>/edit'" do
|
|
39
|
+
RulesEngine::Rule::<%=rule_class%>.options[:edit_partial].should == '/re_rules/<%=rule_name%>/edit'
|
|
40
40
|
end
|
|
41
41
|
end
|
|
42
42
|
|
|
@@ -55,8 +55,8 @@ describe RulesEngine::Rule::<%=rule_class%> do
|
|
|
55
55
|
@<%=rule_name%>.title.should == "Rule Title"
|
|
56
56
|
end
|
|
57
57
|
|
|
58
|
-
it "should set the
|
|
59
|
-
@<%=rule_name%>.
|
|
58
|
+
it "should set the plan_code" do
|
|
59
|
+
@<%=rule_name%>.plan_code.should == "Other Plan"
|
|
60
60
|
end
|
|
61
61
|
end
|
|
62
62
|
|
|
@@ -67,18 +67,18 @@ describe RulesEngine::Rule::<%=rule_class%> do
|
|
|
67
67
|
@<%=rule_name%>.title.should be_nil
|
|
68
68
|
end
|
|
69
69
|
|
|
70
|
-
it "should set the '
|
|
71
|
-
@<%=rule_name%>.
|
|
70
|
+
it "should set the 'plan_code' to nil" do
|
|
71
|
+
@<%=rule_name%>.plan_code.should_not be_nil
|
|
72
72
|
@<%=rule_name%>.data = nil
|
|
73
|
-
@<%=rule_name%>.
|
|
73
|
+
@<%=rule_name%>.plan_code.should be_nil
|
|
74
74
|
end
|
|
75
75
|
end
|
|
76
76
|
end
|
|
77
77
|
|
|
78
78
|
describe "the summary" do
|
|
79
|
-
it "should show the
|
|
79
|
+
it "should show the plan_code" do
|
|
80
80
|
<%=rule_name%> = RulesEngine::Rule::<%=rule_class%>.new
|
|
81
|
-
<%=rule_name%>.stub!(:
|
|
81
|
+
<%=rule_name%>.stub!(:plan_code).and_return("mock")
|
|
82
82
|
<%=rule_name%>.summary.should == "Run the plan : mock"
|
|
83
83
|
end
|
|
84
84
|
end
|
|
@@ -87,8 +87,8 @@ describe RulesEngine::Rule::<%=rule_class%> do
|
|
|
87
87
|
it "should be converted to a json string" do
|
|
88
88
|
<%=rule_name%> = RulesEngine::Rule::<%=rule_class%>.new
|
|
89
89
|
<%=rule_name%>.should_receive(:title).and_return("mock title")
|
|
90
|
-
<%=rule_name%>.should_receive(:
|
|
91
|
-
<%=rule_name%>.data.should == '["mock title","plan"]'
|
|
90
|
+
<%=rule_name%>.should_receive(:plan_code).and_return("mock plan name")
|
|
91
|
+
<%=rule_name%>.data.should == '["mock title","mock plan name"]'
|
|
92
92
|
end
|
|
93
93
|
end
|
|
94
94
|
|
|
@@ -133,19 +133,19 @@ describe RulesEngine::Rule::<%=rule_class%> do
|
|
|
133
133
|
it "should be valid with valid '<%=rule_name%>_plan'" do
|
|
134
134
|
@<%=rule_name%>.attributes = valid_attributes
|
|
135
135
|
@<%=rule_name%>.should be_valid
|
|
136
|
-
@<%=rule_name%>.
|
|
136
|
+
@<%=rule_name%>.plan_code.should == 'Next Plan'
|
|
137
137
|
end
|
|
138
138
|
|
|
139
|
-
it "should not be valid if the '<%=rule_name%>
|
|
140
|
-
@<%=rule_name%>.attributes = valid_attributes.except(:<%=rule_name%>
|
|
139
|
+
it "should not be valid if the '<%=rule_name%>_plan_code' attribute is missing" do
|
|
140
|
+
@<%=rule_name%>.attributes = valid_attributes.except(:<%=rule_name%>_plan_code)
|
|
141
141
|
@<%=rule_name%>.should_not be_valid
|
|
142
|
-
@<%=rule_name%>.errors.should include(:<%=rule_name%>
|
|
142
|
+
@<%=rule_name%>.errors.should include(:<%=rule_name%>_plan_code)
|
|
143
143
|
end
|
|
144
144
|
|
|
145
|
-
it "should not be valid if the '<%=rule_name%>
|
|
146
|
-
@<%=rule_name%>.attributes = valid_attributes.merge(:<%=rule_name%>
|
|
145
|
+
it "should not be valid if the '<%=rule_name%>_plan_code' attribute is blank" do
|
|
146
|
+
@<%=rule_name%>.attributes = valid_attributes.merge(:<%=rule_name%>_plan_code => "")
|
|
147
147
|
@<%=rule_name%>.should_not be_valid
|
|
148
|
-
@<%=rule_name%>.errors.should include(:<%=rule_name%>
|
|
148
|
+
@<%=rule_name%>.errors.should include(:<%=rule_name%>_plan_code)
|
|
149
149
|
end
|
|
150
150
|
end
|
|
151
151
|
end
|
|
@@ -165,26 +165,27 @@ describe RulesEngine::Rule::<%=rule_class%> do
|
|
|
165
165
|
describe "processing the rule" do
|
|
166
166
|
before(:each) do
|
|
167
167
|
@<%=rule_name%> = RulesEngine::Rule::<%=rule_class%>.new
|
|
168
|
-
@<%=rule_name%>.stub!(:
|
|
168
|
+
@<%=rule_name%>.stub!(:plan_code).and_return('sub_plan')
|
|
169
169
|
|
|
170
170
|
RulesEngine::Process.runner.stub!(:create).and_return(1003)
|
|
171
|
-
RulesEngine::Process.runner.stub!(:
|
|
171
|
+
RulesEngine::Process.runner.stub!(:run_plan)
|
|
172
172
|
end
|
|
173
173
|
|
|
174
|
-
it "should
|
|
174
|
+
it "should run the plan" do
|
|
175
175
|
RulesEngine::Process.runner.should_receive(:create).and_return(1003)
|
|
176
|
-
RulesEngine::
|
|
177
|
-
|
|
176
|
+
RulesEngine::Publish.publisher.should_receive(:get).with('sub_plan').and_return({:sub_plan => "data"})
|
|
177
|
+
RulesEngine::Process.runner.should_receive(:run_plan).with(1003, {:sub_plan => "data"}, {:origional => "data"})
|
|
178
|
+
@<%=rule_name%>.process(1003, {:plan => "plan"}, {:origional => "data"})
|
|
178
179
|
end
|
|
179
180
|
|
|
180
181
|
it "should return outcome next if the plan was successful" do
|
|
181
|
-
RulesEngine::Process.runner.stub!(:
|
|
182
|
-
@<%=rule_name%>.process(1003, {}).outcome.should == RulesEngine::Rule::Outcome::NEXT
|
|
182
|
+
RulesEngine::Process.runner.stub!(:run_plan).and_return(true)
|
|
183
|
+
@<%=rule_name%>.process(1003, {:plan => "plan"}, {}).outcome.should == RulesEngine::Rule::Outcome::NEXT
|
|
183
184
|
end
|
|
184
185
|
|
|
185
186
|
it "should return outcome stop failure if the plan failed" do
|
|
186
|
-
RulesEngine::Process.runner.stub!(:
|
|
187
|
-
@<%=rule_name%>.process(1003, {}).outcome.should == RulesEngine::Rule::Outcome::STOP_FAILURE
|
|
187
|
+
RulesEngine::Process.runner.stub!(:run_plan).and_return(false)
|
|
188
|
+
@<%=rule_name%>.process(1003, {:plan => "plan"}, {}).outcome.should == RulesEngine::Rule::Outcome::STOP_FAILURE
|
|
188
189
|
end
|
|
189
190
|
end
|
|
190
191
|
end
|
|
@@ -218,7 +219,7 @@ describe ReWorkflowRulesController, :type => :controller do
|
|
|
218
219
|
get :new, :rule_class_name => "RulesEngine::Rule::<%=rule_class%>"
|
|
219
220
|
response.should have_tag("form#re_rule_new_form") do
|
|
220
221
|
with_tag("input#<%=rule_name%>_title")
|
|
221
|
-
with_tag("input#<%=rule_name%>
|
|
222
|
+
with_tag("input#<%=rule_name%>_plan_code")
|
|
222
223
|
end
|
|
223
224
|
end
|
|
224
225
|
end
|
|
@@ -233,7 +234,7 @@ describe ReWorkflowRulesController, :type => :controller do
|
|
|
233
234
|
get :edit, :re_workflow_id => @re_workflow.id, :re_rule_id => 1001, :rule_class_name => "RulesEngine::Rule::<%=rule_class%>"
|
|
234
235
|
response.should have_tag("form#re_rule_edit_form") do
|
|
235
236
|
with_tag("input#<%=rule_name%>_title", :value => 'Rule Title')
|
|
236
|
-
with_tag("input#<%=rule_name%>
|
|
237
|
+
with_tag("input#<%=rule_name%>_plan_code", :value => 'Other Plan')
|
|
237
238
|
end
|
|
238
239
|
end
|
|
239
240
|
end
|
|
@@ -26,16 +26,16 @@ describe RulesEngine::Rule::<%=rule_class%> do
|
|
|
26
26
|
RulesEngine::Rule::<%=rule_class%>.options[:display_name].should == "Twitter Filter Retweets"
|
|
27
27
|
end
|
|
28
28
|
|
|
29
|
-
it "should have the help template of '/
|
|
30
|
-
RulesEngine::Rule::<%=rule_class%>.options[:help_partial].should == '/
|
|
29
|
+
it "should have the help template of '/re_rules/<%=rule_name%>/help'" do
|
|
30
|
+
RulesEngine::Rule::<%=rule_class%>.options[:help_partial].should == '/re_rules/<%=rule_name%>/help'
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
-
it "should have the new template of '/
|
|
34
|
-
RulesEngine::Rule::<%=rule_class%>.options[:new_partial].should == '/
|
|
33
|
+
it "should have the new template of '/re_rules/<%=rule_name%>/new'" do
|
|
34
|
+
RulesEngine::Rule::<%=rule_class%>.options[:new_partial].should == '/re_rules/<%=rule_name%>/new'
|
|
35
35
|
end
|
|
36
36
|
|
|
37
|
-
it "should have the edit view partial template of '/
|
|
38
|
-
RulesEngine::Rule::<%=rule_class%>.options[:edit_partial].should == '/
|
|
37
|
+
it "should have the edit view partial template of '/re_rules/<%=rule_name%>/edit'" do
|
|
38
|
+
RulesEngine::Rule::<%=rule_class%>.options[:edit_partial].should == '/re_rules/<%=rule_name%>/edit'
|
|
39
39
|
end
|
|
40
40
|
end
|
|
41
41
|
|
|
@@ -135,11 +135,11 @@ describe RulesEngine::Rule::<%=rule_class%> do
|
|
|
135
135
|
end
|
|
136
136
|
|
|
137
137
|
it "should do nothing if there is no tweet" do
|
|
138
|
-
@filter.process(1001, {}).outcome.should == RulesEngine::Rule::Outcome::NEXT
|
|
138
|
+
@filter.process(1001, {:plan => "plan"}, {}).outcome.should == RulesEngine::Rule::Outcome::NEXT
|
|
139
139
|
end
|
|
140
140
|
|
|
141
141
|
it "should do nothing if there is no match" do
|
|
142
|
-
@filter.process(@job, {:tweet => "RTnot here"}).outcome.should == RulesEngine::Rule::Outcome::NEXT
|
|
142
|
+
@filter.process(@job, {:plan => "plan"}, {:tweet => "RTnot here"}).outcome.should == RulesEngine::Rule::Outcome::NEXT
|
|
143
143
|
end
|
|
144
144
|
|
|
145
145
|
describe "a match found" do
|
|
@@ -152,11 +152,11 @@ describe RulesEngine::Rule::<%=rule_class%> do
|
|
|
152
152
|
process_id.should == 1001
|
|
153
153
|
message.should =~ /^Found retweet$/
|
|
154
154
|
end
|
|
155
|
-
@filter.process(1001, @matched_data)
|
|
155
|
+
@filter.process(1001, {:plan => "plan"}, @matched_data)
|
|
156
156
|
end
|
|
157
157
|
|
|
158
158
|
it "should return stop_success" do
|
|
159
|
-
@filter.process(1001, @matched_data).outcome.should == RulesEngine::Rule::Outcome::STOP_SUCCESS
|
|
159
|
+
@filter.process(1001, {:plan => "plan"}, @matched_data).outcome.should == RulesEngine::Rule::Outcome::STOP_SUCCESS
|
|
160
160
|
end
|
|
161
161
|
end
|
|
162
162
|
end
|