rules_view 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +20 -0
- data/README.textile +129 -0
- data/Rakefile +47 -0
- data/VERSION +1 -0
- data/app/views/layouts/rules_view.html.erb +43 -0
- data/app/views/re_view/template.html.erb +196 -0
- data/autotest/discover.rb +2 -0
- data/generators/install_generator.rb +41 -0
- data/generators/layout_generator.rb +41 -0
- data/generators/manifests/application.rb +116 -0
- data/generators/manifests/application.yml +8 -0
- data/generators/manifests/layout.rb +17 -0
- data/generators/manifests/layout.yml +5 -0
- data/generators/manifests/templates/app/views/layouts/rules_view_layout.html.erb +47 -0
- data/generators/manifests/templates/config/initializers/rules_view.rb +1 -0
- data/generators/manifests/templates/doc/README.rules_view +97 -0
- data/generators/manifests/templates/public/javascripts/rules_view/jquery-1.4.2.min.js +154 -0
- data/generators/manifests/templates/public/javascripts/rules_view/jquery.autocomplete.pack.js +13 -0
- data/generators/manifests/templates/public/javascripts/rules_view/jquery.blockUI.js +486 -0
- data/generators/manifests/templates/public/javascripts/rules_view/jquery.fancybox-1.3.1.js +1077 -0
- data/generators/manifests/templates/public/javascripts/rules_view/re_view.js +148 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/blueprint/ie.css +35 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/blueprint/plugins/buttons/icons/cross.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/blueprint/plugins/buttons/icons/key.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/blueprint/plugins/buttons/icons/tick.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/blueprint/plugins/buttons/readme.txt +32 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/blueprint/plugins/buttons/screen.css +97 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/blueprint/plugins/fancy-type/readme.txt +14 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/blueprint/plugins/fancy-type/screen.css +71 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/blueprint/plugins/link-icons/icons/doc.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/blueprint/plugins/link-icons/icons/email.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/blueprint/plugins/link-icons/icons/external.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/blueprint/plugins/link-icons/icons/feed.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/blueprint/plugins/link-icons/icons/im.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/blueprint/plugins/link-icons/icons/pdf.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/blueprint/plugins/link-icons/icons/visited.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/blueprint/plugins/link-icons/icons/xls.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/blueprint/plugins/link-icons/readme.txt +18 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/blueprint/plugins/link-icons/screen.css +40 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/blueprint/plugins/rtl/readme.txt +10 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/blueprint/plugins/rtl/screen.css +110 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/blueprint/print.css +29 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/blueprint/screen.css +258 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/blueprint/src/forms.css +65 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/blueprint/src/grid.css +280 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/blueprint/src/grid.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/blueprint/src/ie.css +76 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/blueprint/src/print.css +85 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/blueprint/src/reset.css +45 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/blueprint/src/typography.css +106 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/fancybox/blank.gif +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/fancybox/fancy_close.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/fancybox/fancy_loading.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/fancybox/fancy_nav_left.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/fancybox/fancy_nav_right.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/fancybox/fancy_shadow_e.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/fancybox/fancy_shadow_n.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/fancybox/fancy_shadow_ne.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/fancybox/fancy_shadow_nw.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/fancybox/fancy_shadow_s.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/fancybox/fancy_shadow_se.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/fancybox/fancy_shadow_sw.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/fancybox/fancy_shadow_w.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/fancybox/fancy_title_left.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/fancybox/fancy_title_main.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/fancybox/fancy_title_over.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/fancybox/fancy_title_right.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/fancybox/fancybox-x.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/fancybox/fancybox-y.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/fancybox/fancybox.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/fancybox/jquery.fancybox-1.3.1.css +363 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/images/re_view_box/shadowbox.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/images/re_view_box/whitebox.jpg +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/images/re_view_button/checked-off.gif +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/images/re_view_button/checked-on.gif +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/images/re_view_button/icon-add.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/images/re_view_button/icon-delete.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/images/re_view_button/list-add.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/images/re_view_button/list-remove.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/images/re_view_button/list-select.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/images/re_view_button/oval-blue-left.gif +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/images/re_view_button/oval-blue-right.gif +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/images/re_view_button/oval-gray-left.gif +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/images/re_view_button/oval-gray-right.gif +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/images/re_view_button/oval-green-left.gif +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/images/re_view_button/oval-green-right.gif +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/images/re_view_button/oval-orange-left.gif +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/images/re_view_button/oval-orange-right.gif +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/images/re_view_button/oval-red-left.gif +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/images/re_view_button/oval-red-right.gif +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/images/re_view_error/re-alert-close.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/images/re_view_navigate/breadcrumb.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/jquery.autocomplete.css +53 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/rules_view.css +738 -0
- data/init.rb +1 -0
- data/lib/rules_view/alerts.rb +51 -0
- data/lib/rules_view/boxes.rb +25 -0
- data/lib/rules_view/buttons.rb +113 -0
- data/lib/rules_view/config.rb +21 -0
- data/lib/rules_view/defer.rb +30 -0
- data/lib/rules_view/engine.rb +28 -0
- data/lib/rules_view/form_builder.rb +62 -0
- data/lib/rules_view/form_fields.rb +41 -0
- data/lib/rules_view/form_styles.rb +112 -0
- data/lib/rules_view/model_loader.rb +64 -0
- data/lib/rules_view/navigate.rb +40 -0
- data/lib/rules_view.rb +20 -0
- data/rules_view.gemspec +239 -0
- data/spec/lib/rules_view/alerts_spec.rb +145 -0
- data/spec/lib/rules_view/boxes_spec.rb +49 -0
- data/spec/lib/rules_view/buttons_spec.rb +184 -0
- data/spec/lib/rules_view/defer_spec.rb +90 -0
- data/spec/lib/rules_view/form_builder_fields_spec.rb +184 -0
- data/spec/lib/rules_view/form_builder_spec.rb +19 -0
- data/spec/lib/rules_view/form_fields_spec.rb +219 -0
- data/spec/lib/rules_view/form_styles_spec.rb +290 -0
- data/spec/lib/rules_view/model_loader_spec.rb +202 -0
- data/spec/lib/rules_view/navigate_spec.rb +61 -0
- data/spec/rails_3_0_0_root/.gitignore +4 -0
- data/spec/rails_3_0_0_root/.rspec +1 -0
- data/spec/rails_3_0_0_root/Gemfile +13 -0
- data/spec/rails_3_0_0_root/Gemfile.lock +101 -0
- data/spec/rails_3_0_0_root/README +256 -0
- data/spec/rails_3_0_0_root/Rakefile +7 -0
- data/spec/rails_3_0_0_root/app/controllers/application_controller.rb +3 -0
- data/spec/rails_3_0_0_root/app/helpers/application_helper.rb +2 -0
- data/spec/rails_3_0_0_root/app/views/layouts/application.html.erb +14 -0
- data/spec/rails_3_0_0_root/autotest/discover.rb +2 -0
- data/spec/rails_3_0_0_root/config/application.rb +42 -0
- data/spec/rails_3_0_0_root/config/boot.rb +13 -0
- data/spec/rails_3_0_0_root/config/database.yml +22 -0
- data/spec/rails_3_0_0_root/config/environment.rb +5 -0
- data/spec/rails_3_0_0_root/config/environments/development.rb +26 -0
- data/spec/rails_3_0_0_root/config/environments/production.rb +49 -0
- data/spec/rails_3_0_0_root/config/environments/test.rb +35 -0
- data/spec/rails_3_0_0_root/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/rails_3_0_0_root/config/initializers/inflections.rb +10 -0
- data/spec/rails_3_0_0_root/config/initializers/mime_types.rb +5 -0
- data/spec/rails_3_0_0_root/config/initializers/secret_token.rb +7 -0
- data/spec/rails_3_0_0_root/config/initializers/session_store.rb +8 -0
- data/spec/rails_3_0_0_root/config/locales/en.yml +5 -0
- data/spec/rails_3_0_0_root/config/routes.rb +58 -0
- data/spec/rails_3_0_0_root/config.ru +4 -0
- data/spec/rails_3_0_0_root/db/seeds.rb +7 -0
- data/spec/rails_3_0_0_root/doc/README_FOR_APP +2 -0
- data/spec/rails_3_0_0_root/lib/tasks/.gitkeep +0 -0
- data/spec/rails_3_0_0_root/public/404.html +26 -0
- data/spec/rails_3_0_0_root/public/422.html +26 -0
- data/spec/rails_3_0_0_root/public/500.html +26 -0
- data/spec/rails_3_0_0_root/public/favicon.ico +0 -0
- data/spec/rails_3_0_0_root/public/images/rails.png +0 -0
- data/spec/rails_3_0_0_root/public/index.html +239 -0
- data/spec/rails_3_0_0_root/public/javascripts/application.js +2 -0
- data/spec/rails_3_0_0_root/public/javascripts/controls.js +965 -0
- data/spec/rails_3_0_0_root/public/javascripts/dragdrop.js +974 -0
- data/spec/rails_3_0_0_root/public/javascripts/effects.js +1123 -0
- data/spec/rails_3_0_0_root/public/javascripts/prototype.js +6001 -0
- data/spec/rails_3_0_0_root/public/javascripts/rails.js +175 -0
- data/spec/rails_3_0_0_root/public/robots.txt +5 -0
- data/spec/rails_3_0_0_root/public/stylesheets/.gitkeep +0 -0
- data/spec/rails_3_0_0_root/script/rails +6 -0
- data/spec/rails_3_0_0_root/spec/spec_helper.rb +27 -0
- data/spec/rails_3_0_0_root/vendor/plugins/.gitkeep +0 -0
- data/spec/spec_helper.rb +29 -0
- data/spec/support/create_memory_db.rb +2 -0
- data/tasks/rspec.rake +46 -0
- metadata +278 -0
@@ -0,0 +1,290 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
2
|
+
|
3
|
+
describe "re_build_form_field" do
|
4
|
+
include RSpec::Rails::HelperExampleGroup
|
5
|
+
|
6
|
+
it "should be accessible to rails apps by default" do
|
7
|
+
ActionView::Base.new.methods.should include("re_build_form_field")
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should be html safe" do
|
11
|
+
helper.re_build_form_field("default value").should be_html_safe
|
12
|
+
helper.re_build_form_field("<default value>").should =~/<default value>/
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should set the default class to re-form-field" do
|
16
|
+
helper.re_build_form_field("default value").should have_selector("div.re-form-field", :content => "default value")
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should be disabled if set" do
|
20
|
+
helper.re_build_form_field("default value", :disabled => true).should have_selector("div.re-form-field.re-form-disabled")
|
21
|
+
helper.re_build_form_field("default value", :disabled => false).should_not have_selector("div.re-form-field.re-form-disabled")
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should add the class if set" do
|
25
|
+
helper.re_build_form_field("default value", :class => "test-class").should have_selector("div.re-form-field.test-class")
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should set the default span to 12" do
|
29
|
+
helper.re_build_form_field("default value").should have_selector("div.re-form-field.span-12")
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should use the value of the span option" do
|
33
|
+
helper.re_build_form_field("default value", :span => '22').should have_selector("div.re-form-field.span-22")
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should use the clear class to ensure each field is at the start of the section" do
|
37
|
+
helper.re_build_form_field("default value").should have_selector("div.re-form-field.clear")
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should set the id for the field to form_field_[id]" do
|
41
|
+
helper.re_build_form_field("default value", :id => "NEW").should have_selector("div.re-form-field#form_field_NEW")
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "re_build_form_label" do
|
46
|
+
include RSpec::Rails::HelperExampleGroup
|
47
|
+
|
48
|
+
it "should be accessible to rails apps by default" do
|
49
|
+
ActionView::Base.new.methods.should include("re_build_form_label")
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should be html safe" do
|
53
|
+
helper.re_build_form_label("default value").should be_html_safe
|
54
|
+
helper.re_build_form_label("<default value>").should =~/<default value>/
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should set the default class to re-form-label" do
|
58
|
+
helper.re_build_form_label("default value").should have_selector("div.re-form-label", :content => "default value")
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should set the default class to re-form-label-error if there is an error set" do
|
62
|
+
helper.re_build_form_label("default value", :error => "ouch").should have_selector("div.re-form-label-error")
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should be disabled if set" do
|
66
|
+
helper.re_build_form_label("default value", :disabled => true).should have_selector("div.re-form-label.re-form-disabled")
|
67
|
+
helper.re_build_form_label("default value", :disabled => false).should_not have_selector("div.re-form-label.re-form-disabled")
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should add the class if set" do
|
71
|
+
helper.re_build_form_label("default value", :class => "test-class").should have_selector("div.re-form-label.test-class")
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should set the default span to 4" do
|
75
|
+
helper.re_build_form_label("default value").should have_selector("div.re-form-label.span-4")
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should use the value of the span option" do
|
79
|
+
helper.re_build_form_label("default value", :span => '22').should have_selector("div.re-form-label.span-22")
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should set the id for the field to re_form_label_[id]" do
|
83
|
+
helper.re_build_form_label("default value", :id => "NEW").should have_selector("div#re_form_label_NEW")
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should include a span.re-form-required > * when required set" do
|
87
|
+
helper.re_build_form_label("default value", :required => "true").should have_selector("div") do |div|
|
88
|
+
div.should have_selector("span.re-form-required", :content => "*")
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
it "should include a span.re-form-required.re-form-disabled > * when required set" do
|
93
|
+
helper.re_build_form_label("default value", :required => "true", :disabled => "true").should have_selector("div") do |div|
|
94
|
+
div.should have_selector("span.re-form-required.re-form-disabled", :content => "*")
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
describe "re_build_form_data" do
|
100
|
+
include RSpec::Rails::HelperExampleGroup
|
101
|
+
|
102
|
+
it "should be accessible to rails apps by default" do
|
103
|
+
ActionView::Base.new.methods.should include("re_build_form_data")
|
104
|
+
end
|
105
|
+
|
106
|
+
it "should be html safe" do
|
107
|
+
helper.re_build_form_data("default value").should be_html_safe
|
108
|
+
helper.re_build_form_data("<default value>").should =~/<default value>/
|
109
|
+
end
|
110
|
+
|
111
|
+
it "should set the default class to re-form-data" do
|
112
|
+
helper.re_build_form_data("default value").should have_selector("div.re-form-data", :content => "default value")
|
113
|
+
end
|
114
|
+
|
115
|
+
it "should set the default class to re-form-data-error if there is an error set" do
|
116
|
+
helper.re_build_form_data("default value", :error => "ouch").should have_selector("div.re-form-data-error")
|
117
|
+
end
|
118
|
+
|
119
|
+
it "should be disabled if set" do
|
120
|
+
helper.re_build_form_data("default value", :disabled => true).should have_selector("div.re-form-data.re-form-disabled")
|
121
|
+
helper.re_build_form_data("default value", :disabled => false).should_not have_selector("div.re-form-data.re-form-disabled")
|
122
|
+
end
|
123
|
+
|
124
|
+
it "should add the class if set" do
|
125
|
+
helper.re_build_form_data("default value", :class => "test-class").should have_selector("div.re-form-data.test-class")
|
126
|
+
end
|
127
|
+
|
128
|
+
it "should set the default span to 8" do
|
129
|
+
helper.re_build_form_data("default value").should have_selector("div.re-form-data.span-8")
|
130
|
+
end
|
131
|
+
|
132
|
+
it "should use the value of the span option" do
|
133
|
+
helper.re_build_form_data("default value", :span => '22').should have_selector("div.re-form-data.span-22")
|
134
|
+
end
|
135
|
+
|
136
|
+
it "should use the last class to ensure it is the last field in a section" do
|
137
|
+
helper.re_build_form_data("default value").should have_selector("div.re-form-data.last")
|
138
|
+
end
|
139
|
+
|
140
|
+
it "should set the id for the field to form_value_[id]" do
|
141
|
+
helper.re_build_form_data("default value", :id => "NEW").should have_selector("div.re-form-data#form_data_NEW")
|
142
|
+
end
|
143
|
+
|
144
|
+
it "should add a form-hint span if :hint set" do
|
145
|
+
helper.re_build_form_data("default value", :error => "", :hint => "hint value").should have_selector("div.re-form-data > span.form-hint", :content => "hint value")
|
146
|
+
end
|
147
|
+
|
148
|
+
it "should not add a form-hint span if :hint set but there is an error" do
|
149
|
+
helper.re_build_form_data("default value", :error => "ouch", :hint => "hint value").should_not have_selector("span.form-hint")
|
150
|
+
end
|
151
|
+
|
152
|
+
it "should not add a form-hint span if :hint is blank" do
|
153
|
+
helper.re_build_form_data("default value", :hint => "").should_not have_selector("span.form-hint")
|
154
|
+
end
|
155
|
+
|
156
|
+
it "should add a form-txt span if :text set" do
|
157
|
+
helper.re_build_form_data("default value", :text => "text value").should have_selector("div.re-form-data > span.form-text", :content => "text value")
|
158
|
+
end
|
159
|
+
|
160
|
+
it "should not add a form-txt span if :text is blank" do
|
161
|
+
helper.re_build_form_data("default value", :text => "").should_not have_selector("div.re-form-data > span.form-text")
|
162
|
+
end
|
163
|
+
|
164
|
+
it "should not add a form-txt span if :text is blank" do
|
165
|
+
helper.re_build_form_data("default value", :text => "").should_not have_selector("span.form-text")
|
166
|
+
end
|
167
|
+
|
168
|
+
it "should add a form-error-message span if :error set" do
|
169
|
+
helper.re_build_form_data("default value", :error => "error value").should have_selector("div.re-form-data-error > span.form-error-message", :content => "error value")
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
describe "re_options_exclude", :type => :helper do
|
174
|
+
include RSpec::Rails::HelperExampleGroup
|
175
|
+
|
176
|
+
it "should be accessible to rails apps by default" do
|
177
|
+
ActionView::Base.new.methods.should include("re_options_exclude")
|
178
|
+
end
|
179
|
+
|
180
|
+
[:error, :hint, :label, :text, :required, :span].each do |option|
|
181
|
+
it "should remove the option #{option}" do
|
182
|
+
options = {:a =>"a", :b =>"b", :c =>"c", option => "option"}
|
183
|
+
helper.re_options_exclude(options).should == {:a =>"a", :b =>"b", :c =>"c"}
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
describe "re_label_span" do
|
189
|
+
include RSpec::Rails::HelperExampleGroup
|
190
|
+
|
191
|
+
it "should be accessible to rails apps by default" do
|
192
|
+
ActionView::Base.new.methods.should include("re_label_span")
|
193
|
+
end
|
194
|
+
|
195
|
+
it "should be set to 4 by default" do
|
196
|
+
helper.re_label_span({}).should == 4
|
197
|
+
helper.re_label_span(:span => 'X').should == 4
|
198
|
+
end
|
199
|
+
|
200
|
+
it "should use the first value of a NxN span" do
|
201
|
+
helper.re_label_span(:span => '2x10').should == 2
|
202
|
+
helper.re_label_span(:span => '20x10').should == 20
|
203
|
+
end
|
204
|
+
|
205
|
+
it "should use the value of a N span" do
|
206
|
+
helper.re_label_span(:span => '2').should == 2
|
207
|
+
helper.re_label_span(:span => '20').should == 20
|
208
|
+
end
|
209
|
+
|
210
|
+
end
|
211
|
+
|
212
|
+
describe "re_data_span" do
|
213
|
+
include RSpec::Rails::HelperExampleGroup
|
214
|
+
|
215
|
+
it "should be accessible to rails apps by default" do
|
216
|
+
ActionView::Base.new.methods.should include("re_data_span")
|
217
|
+
end
|
218
|
+
|
219
|
+
it "should be set to 8 by default" do
|
220
|
+
helper.re_data_span({}).should == 8
|
221
|
+
helper.re_data_span(:span => 'X').should == 8
|
222
|
+
end
|
223
|
+
|
224
|
+
it "should use the second value of a NxN span" do
|
225
|
+
helper.re_data_span(:span => '2x10').should == 10
|
226
|
+
helper.re_data_span(:span => '2x20').should == 20
|
227
|
+
end
|
228
|
+
|
229
|
+
it "should be 8, 16, 24 minus the value of a N span" do
|
230
|
+
helper.re_data_span(:span => '0').should == 8
|
231
|
+
helper.re_data_span(:span => '1').should == 7
|
232
|
+
helper.re_data_span(:span => '7').should == 1
|
233
|
+
helper.re_data_span(:span => '8').should == 8
|
234
|
+
helper.re_data_span(:span => '9').should == 7
|
235
|
+
helper.re_data_span(:span => '15').should == 1
|
236
|
+
helper.re_data_span(:span => '16').should == 8
|
237
|
+
helper.re_data_span(:span => '17').should == 7
|
238
|
+
end
|
239
|
+
|
240
|
+
end
|
241
|
+
|
242
|
+
describe "re_field_span" do
|
243
|
+
include RSpec::Rails::HelperExampleGroup
|
244
|
+
|
245
|
+
it "should be accessible to rails apps by default" do
|
246
|
+
ActionView::Base.new.methods.should include("re_field_span")
|
247
|
+
end
|
248
|
+
|
249
|
+
it "should be set to 12 by default" do
|
250
|
+
helper.re_field_span({}).should == 12
|
251
|
+
end
|
252
|
+
|
253
|
+
it "should use the sum of a NxN span" do
|
254
|
+
helper.re_field_span(:span => '2x7').should == 9
|
255
|
+
helper.re_field_span(:span => '2x10').should == 12
|
256
|
+
helper.re_field_span(:span => '2x20').should == 22
|
257
|
+
end
|
258
|
+
|
259
|
+
it "should be in columns of 8, 16 or 24 " do
|
260
|
+
helper.re_field_span(:span => '0').should == 8
|
261
|
+
helper.re_field_span(:span => '1').should == 8
|
262
|
+
helper.re_field_span(:span => '7').should == 8
|
263
|
+
helper.re_field_span(:span => '8').should == 16
|
264
|
+
helper.re_field_span(:span => '9').should == 16
|
265
|
+
helper.re_field_span(:span => '15').should == 16
|
266
|
+
helper.re_field_span(:span => '16').should == 24
|
267
|
+
helper.re_field_span(:span => '17').should == 24
|
268
|
+
end
|
269
|
+
end
|
270
|
+
|
271
|
+
describe "re_error_on_tag" do
|
272
|
+
include RSpec::Rails::HelperExampleGroup
|
273
|
+
|
274
|
+
it "should be accessible to rails apps by default" do
|
275
|
+
ActionView::Base.new.methods.should include("re_error_on_tag")
|
276
|
+
end
|
277
|
+
|
278
|
+
it "should be html safe" do
|
279
|
+
helper.re_error_on_tag("The Error Message to Show").should be_html_safe
|
280
|
+
helper.re_error_on_tag("<The Error Message to Show>").should have_selector('div.re-error > p') do |error_message|
|
281
|
+
error_message.inner_html.should == "<The Error Message to Show>"
|
282
|
+
end
|
283
|
+
end
|
284
|
+
|
285
|
+
it "should display the error" do
|
286
|
+
helper.re_error_on_tag("The Error Message to Show").should have_selector('div.re-error > p', :content => "The Error Message to Show")
|
287
|
+
end
|
288
|
+
end
|
289
|
+
|
290
|
+
|
@@ -0,0 +1,202 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
2
|
+
|
3
|
+
# ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:")
|
4
|
+
|
5
|
+
ActiveRecord::Schema.define(:version => 1) do
|
6
|
+
create_table :posts do |t|
|
7
|
+
end
|
8
|
+
|
9
|
+
create_table :comments do |t|
|
10
|
+
t.integer :post_id
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class Post < ActiveRecord::Base
|
15
|
+
end
|
16
|
+
|
17
|
+
class Comment < ActiveRecord::Base
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "model_loader" do
|
21
|
+
include RSpec::Rails::ControllerExampleGroup
|
22
|
+
|
23
|
+
controller do
|
24
|
+
before_filter do |controller|
|
25
|
+
if params[:post_id]
|
26
|
+
controller.re_load_model :post, :param_id => :post_id
|
27
|
+
if params[:validate]
|
28
|
+
controller.re_load_model :comment, :parents => [:post], :validate => params[:validate]
|
29
|
+
elsif params[:redirect_path]
|
30
|
+
controller.re_load_model :comment, :parents => [:post], :redirect_path => params[:redirect_path]
|
31
|
+
else
|
32
|
+
controller.re_load_model :comment, :parents => [:post]
|
33
|
+
end
|
34
|
+
elsif params[:find_by]
|
35
|
+
controller.re_load_model :post, :find_by => params[:find_by]
|
36
|
+
elsif params[:param_id]
|
37
|
+
controller.re_load_model :post, :param_id => params[:param_id]
|
38
|
+
elsif params[:redirect_path]
|
39
|
+
controller.re_load_model :post, :redirect_path => params[:redirect_path]
|
40
|
+
else
|
41
|
+
controller.re_load_model :post
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def index
|
46
|
+
render :inline => "re_load_model"
|
47
|
+
end
|
48
|
+
|
49
|
+
def posts_path
|
50
|
+
'/posts'
|
51
|
+
end
|
52
|
+
|
53
|
+
def comments_path
|
54
|
+
"/comments"
|
55
|
+
end
|
56
|
+
|
57
|
+
def mock_redirect_path(args = [])
|
58
|
+
"/mock_redirect_path/#{args.map(&:id).join('/')}"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
before(:each) do
|
63
|
+
@post = Post.create
|
64
|
+
@comment = Comment.create(:post_id => @post.id)
|
65
|
+
end
|
66
|
+
|
67
|
+
describe "loading a valid model" do
|
68
|
+
it "should find the model" do
|
69
|
+
Post.should_receive(:send).with(:find, @post.id).and_return(@post)
|
70
|
+
get :index, :id => @post.id
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should set the instance variable '@model'" do
|
74
|
+
get :index, :id => @post.id
|
75
|
+
assigns(:post).should == @post
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
describe "loading an invalid model" do
|
80
|
+
it "should set the inastance variable '@model' to nil" do
|
81
|
+
get :index, :id => "unknown"
|
82
|
+
assigns(:post).should == nil
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should set the error message" do
|
86
|
+
get :index, :id => "unknown"
|
87
|
+
flash[:error].should_not be_blank
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should redirect to the index path of the model" do
|
91
|
+
get :index, :id => "unknown"
|
92
|
+
response.should redirect_to('/posts')
|
93
|
+
end
|
94
|
+
|
95
|
+
it "should set the javascript redirect to the index path of the model" do
|
96
|
+
xhr :get, :index, :id => "unknown"
|
97
|
+
response.body.should == "window.location.href = '\/posts';"
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
describe "the model is a child of the direct parent" do
|
102
|
+
before(:each) do
|
103
|
+
Comment.stub!(:send).with(:find, @comment.id).and_return(@comment)
|
104
|
+
end
|
105
|
+
|
106
|
+
it "should confirm that this model is a child of the direct parent" do
|
107
|
+
@comment.should_receive(:post_id).and_return(@post.id)
|
108
|
+
get :index, :id => @comment.id, :post_id => @post.id
|
109
|
+
assigns(:post).should == @post
|
110
|
+
assigns(:comment).should == @comment
|
111
|
+
end
|
112
|
+
|
113
|
+
describe "the :validate option" do
|
114
|
+
it "should be a valid child if the :validate is true" do
|
115
|
+
@comment.should_receive(:validate_method).and_return(true)
|
116
|
+
get :index, :id => @comment.id, :post_id => @post.id, :validate => "validate_method"
|
117
|
+
assigns(:post).should == @post
|
118
|
+
assigns(:comment).should == @comment
|
119
|
+
end
|
120
|
+
|
121
|
+
it "should be a invalid child if the :validate is false" do
|
122
|
+
@comment.should_receive(:validate_method).and_return(false)
|
123
|
+
get :index, :id => @comment.id, :post_id => @post.id, :validate => "validate_method"
|
124
|
+
assigns(:post).should == @post
|
125
|
+
assigns(:comment).should == nil
|
126
|
+
response.should redirect_to('/comments')
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
describe "the model is not a child of the direct parent" do
|
132
|
+
before(:each) do
|
133
|
+
Comment.stub!(:send).with(:find, @comment.id).and_return(@comment)
|
134
|
+
@comment.stub!(:post_id).and_return(-1)
|
135
|
+
end
|
136
|
+
|
137
|
+
it "should set the inastance variable '@model' to nil" do
|
138
|
+
@comment.should_receive(:post_id).and_return(-1)
|
139
|
+
get :index, :id => @comment.id, :post_id => @post.id
|
140
|
+
assigns(:post).should == @post
|
141
|
+
assigns(:comment).should == nil
|
142
|
+
end
|
143
|
+
|
144
|
+
it "should set the error message" do
|
145
|
+
get :index, :id => @comment.id, :post_id => @post.id
|
146
|
+
flash[:error].should_not be_blank
|
147
|
+
end
|
148
|
+
|
149
|
+
it "should redirect to the index path of the parent" do
|
150
|
+
get :index, :id => @comment.id, :post_id => @post.id
|
151
|
+
response.should redirect_to('/comments')
|
152
|
+
end
|
153
|
+
|
154
|
+
it "should set the javascript redirect to the path of the parent" do
|
155
|
+
xhr :get, :index, :id => @comment.id, :post_id => @post.id
|
156
|
+
response.body.should == "window.location.href = '\/comments';"
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
describe "finding a model" do
|
161
|
+
it "should call find when the parameter :find is not set" do
|
162
|
+
Post.should_receive(:send).with(:find, @post.id).and_return(@post)
|
163
|
+
get :index, :id => @post.id
|
164
|
+
end
|
165
|
+
|
166
|
+
it "should use the parameter :find when set" do
|
167
|
+
Post.should_receive(:send).with(:find_by_mock, @post.id).and_return(@post)
|
168
|
+
get :index, :id => @post.id, :find_by => :find_by_mock
|
169
|
+
end
|
170
|
+
|
171
|
+
it "should use the parameter :param_id when set" do
|
172
|
+
Post.should_receive(:send).with(:find, @post.id).and_return(@post)
|
173
|
+
get :index, :test_post_id => @post.id, :param_id => :test_post_id
|
174
|
+
end
|
175
|
+
|
176
|
+
it "should capture RecordNotFound exceptions and return nil" do
|
177
|
+
Post.should_receive(:send).with(:find, @post.id).and_raise(ActiveRecord::RecordNotFound)
|
178
|
+
lambda {
|
179
|
+
get :index, :id => @post.id
|
180
|
+
}.should_not raise_error
|
181
|
+
|
182
|
+
response.should redirect_to('/posts')
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
describe "redirecting on failure" do
|
187
|
+
it "should call the model's index path the parameter :redirect_path is not set" do
|
188
|
+
get :index, :id => 'unknown'
|
189
|
+
response.should redirect_to('/posts')
|
190
|
+
end
|
191
|
+
|
192
|
+
it "should use the :redirect_path when set" do
|
193
|
+
get :index, :id => 'unknown', :redirect_path => :mock_redirect_path
|
194
|
+
response.should redirect_to('/mock_redirect_path/')
|
195
|
+
end
|
196
|
+
|
197
|
+
it "should pass an array of parent models when the :parents set and :redirect_path set" do
|
198
|
+
get :index, :id => 'unknown', :post_id => @post.id, :redirect_path => :mock_redirect_path
|
199
|
+
response.should redirect_to("/mock_redirect_path/#{@post.id}")
|
200
|
+
end
|
201
|
+
end
|
202
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
2
|
+
|
3
|
+
describe "re_breadcrumbs" do
|
4
|
+
include RSpec::Rails::HelperExampleGroup
|
5
|
+
|
6
|
+
it "should be accessible to rails apps by default" do
|
7
|
+
ActionView::Base.new.methods.should include("re_breadcrumbs")
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should be html safe" do
|
11
|
+
helper.re_breadcrumbs("default value").should be_html_safe
|
12
|
+
helper.re_breadcrumbs("<default value>").should =~/<default value>/
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should set the default class to re-breadcrumbs" do
|
16
|
+
helper.re_breadcrumbs("default value").should have_selector("div.re-breadcrumbs")
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should show the links seperated by a <span>" do
|
20
|
+
helper.re_breadcrumbs("<div id=one>one</div>".html_safe, "<div id=two>two</div>".html_safe, "<div id=last>last</div>".html_safe).should have_selector("div.re-breadcrumbs") do |breadcrumbs|
|
21
|
+
breadcrumbs.should have_selector("div#one", :content => "one")
|
22
|
+
breadcrumbs.should have_selector("div#one + span.re-breadcrumbs-seperator", :content => ">")
|
23
|
+
breadcrumbs.should have_selector("div#one + span + div#two + span + em > div#last")
|
24
|
+
breadcrumbs.should have_selector("div#one + span + div#two", :content => "two")
|
25
|
+
breadcrumbs.should have_selector("div#one + span + div#two + span.re-breadcrumbs-seperator", :content => ">")
|
26
|
+
breadcrumbs.should have_selector("div#one + span + div#two + span + em", :content => "last")
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "re_breadcrumbs_right" do
|
32
|
+
include RSpec::Rails::HelperExampleGroup
|
33
|
+
|
34
|
+
it "should be accessible to rails apps by default" do
|
35
|
+
ActionView::Base.new.methods.should include("re_breadcrumbs_right")
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should be html safe" do
|
39
|
+
helper.re_breadcrumbs_right("default value").should be_html_safe
|
40
|
+
helper.re_breadcrumbs_right("<default value>").should =~/<default value>/
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should set the default class to re-breadcrumbs" do
|
44
|
+
helper.re_breadcrumbs_right("default value").should have_selector("div.re-breadcrumbs") do |breadcrumbs|
|
45
|
+
breadcrumbs.should have_selector("div.re-breadcrumb-right", :content => "default value")
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should show the links seperated by a <span>" do
|
50
|
+
helper.re_breadcrumbs_right("<div id=one>one</div>".html_safe, "<div id=two>two</div>".html_safe, "<div id=last>last</div>".html_safe, "<div id=right>right</div>".html_safe).should have_selector("div.re-breadcrumbs") do |breadcrumbs|
|
51
|
+
breadcrumbs.should have_selector("div#one", :content => "one")
|
52
|
+
breadcrumbs.should have_selector("div#one + span", :content => ">")
|
53
|
+
breadcrumbs.should have_selector("div#one + span + div#two + span + em > div#last")
|
54
|
+
breadcrumbs.should have_selector("div#one + span + div#two", :content => "two")
|
55
|
+
breadcrumbs.should have_selector("div#one + span + div#two + span", :content => ">")
|
56
|
+
breadcrumbs.should have_selector("div#one + span + div#two + span + em", :content => "last")
|
57
|
+
breadcrumbs.should have_selector("div#one + span + div#two + span + em + div.re-breadcrumb-right > div#right", :content => "right")
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
--colour
|
@@ -0,0 +1,101 @@
|
|
1
|
+
PATH
|
2
|
+
remote: /Users/chris/Workspace/chris/Gems/rules_view
|
3
|
+
specs:
|
4
|
+
rules_view (0.0.1)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: http://rubygems.org/
|
8
|
+
specs:
|
9
|
+
abstract (1.0.0)
|
10
|
+
actionmailer (3.0.0)
|
11
|
+
actionpack (= 3.0.0)
|
12
|
+
mail (~> 2.2.5)
|
13
|
+
actionpack (3.0.0)
|
14
|
+
activemodel (= 3.0.0)
|
15
|
+
activesupport (= 3.0.0)
|
16
|
+
builder (~> 2.1.2)
|
17
|
+
erubis (~> 2.6.6)
|
18
|
+
i18n (~> 0.4.1)
|
19
|
+
rack (~> 1.2.1)
|
20
|
+
rack-mount (~> 0.6.12)
|
21
|
+
rack-test (~> 0.5.4)
|
22
|
+
tzinfo (~> 0.3.23)
|
23
|
+
activemodel (3.0.0)
|
24
|
+
activesupport (= 3.0.0)
|
25
|
+
builder (~> 2.1.2)
|
26
|
+
i18n (~> 0.4.1)
|
27
|
+
activerecord (3.0.0)
|
28
|
+
activemodel (= 3.0.0)
|
29
|
+
activesupport (= 3.0.0)
|
30
|
+
arel (~> 1.0.0)
|
31
|
+
tzinfo (~> 0.3.23)
|
32
|
+
activeresource (3.0.0)
|
33
|
+
activemodel (= 3.0.0)
|
34
|
+
activesupport (= 3.0.0)
|
35
|
+
activesupport (3.0.0)
|
36
|
+
arel (1.0.1)
|
37
|
+
activesupport (~> 3.0.0)
|
38
|
+
builder (2.1.2)
|
39
|
+
diff-lcs (1.1.2)
|
40
|
+
erubis (2.6.6)
|
41
|
+
abstract (>= 1.0.0)
|
42
|
+
i18n (0.4.1)
|
43
|
+
mail (2.2.7)
|
44
|
+
activesupport (>= 2.3.6)
|
45
|
+
mime-types
|
46
|
+
treetop (>= 1.4.5)
|
47
|
+
mime-types (1.16)
|
48
|
+
nokogiri (1.4.3.1)
|
49
|
+
polyglot (0.3.1)
|
50
|
+
rack (1.2.1)
|
51
|
+
rack-mount (0.6.13)
|
52
|
+
rack (>= 1.0.0)
|
53
|
+
rack-test (0.5.6)
|
54
|
+
rack (>= 1.0)
|
55
|
+
rails (3.0.0)
|
56
|
+
actionmailer (= 3.0.0)
|
57
|
+
actionpack (= 3.0.0)
|
58
|
+
activerecord (= 3.0.0)
|
59
|
+
activeresource (= 3.0.0)
|
60
|
+
activesupport (= 3.0.0)
|
61
|
+
bundler (~> 1.0.0)
|
62
|
+
railties (= 3.0.0)
|
63
|
+
railties (3.0.0)
|
64
|
+
actionpack (= 3.0.0)
|
65
|
+
activesupport (= 3.0.0)
|
66
|
+
rake (>= 0.8.4)
|
67
|
+
thor (~> 0.14.0)
|
68
|
+
rake (0.8.7)
|
69
|
+
rcov (0.9.9)
|
70
|
+
rspec (2.0.0)
|
71
|
+
rspec-core (= 2.0.0)
|
72
|
+
rspec-expectations (= 2.0.0)
|
73
|
+
rspec-mocks (= 2.0.0)
|
74
|
+
rspec-core (2.0.0)
|
75
|
+
rspec-expectations (2.0.0)
|
76
|
+
diff-lcs (>= 1.1.2)
|
77
|
+
rspec-mocks (2.0.0)
|
78
|
+
rspec-core (= 2.0.0)
|
79
|
+
rspec-expectations (= 2.0.0)
|
80
|
+
rspec-rails (2.0.0)
|
81
|
+
rspec (= 2.0.0)
|
82
|
+
sqlite3-ruby (1.3.1)
|
83
|
+
thor (0.14.3)
|
84
|
+
treetop (1.4.8)
|
85
|
+
polyglot (>= 0.3.1)
|
86
|
+
tzinfo (0.3.23)
|
87
|
+
webrat (0.7.1)
|
88
|
+
nokogiri (>= 1.2.0)
|
89
|
+
rack (>= 1.0)
|
90
|
+
rack-test (>= 0.5.3)
|
91
|
+
|
92
|
+
PLATFORMS
|
93
|
+
ruby
|
94
|
+
|
95
|
+
DEPENDENCIES
|
96
|
+
rails (= 3.0.0)
|
97
|
+
rcov
|
98
|
+
rspec-rails (>= 2.0.0)
|
99
|
+
rules_view!
|
100
|
+
sqlite3-ruby
|
101
|
+
webrat
|