right-rails 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.textile +50 -0
- data/Rakefile +23 -0
- data/generators/right_rails/right_rails_generator.rb +41 -0
- data/generators/right_rails/templates/iframed.html.erb +10 -0
- data/generators/right_scaffold/right_scaffold_generator.rb +53 -0
- data/generators/right_scaffold/templates/controller.rb +99 -0
- data/generators/right_scaffold/templates/helper.rb +2 -0
- data/generators/right_scaffold/templates/layout.html.erb +18 -0
- data/generators/right_scaffold/templates/style.css +54 -0
- data/generators/right_scaffold/templates/view__form.html.erb +16 -0
- data/generators/right_scaffold/templates/view__item.html.erb +13 -0
- data/generators/right_scaffold/templates/view_edit.html.erb +6 -0
- data/generators/right_scaffold/templates/view_index.html.erb +9 -0
- data/generators/right_scaffold/templates/view_new.html.erb +5 -0
- data/generators/right_scaffold/templates/view_show.html.erb +10 -0
- data/init.rb +12 -0
- data/javascripts/right-autocompleter-src.js +303 -0
- data/javascripts/right-autocompleter.js +9 -0
- data/javascripts/right-behavior-src.js +240 -0
- data/javascripts/right-behavior.js +8 -0
- data/javascripts/right-calendar-src.js +855 -0
- data/javascripts/right-calendar.js +9 -0
- data/javascripts/right-dnd-src.js +555 -0
- data/javascripts/right-dnd.js +9 -0
- data/javascripts/right-effects-src.js +425 -0
- data/javascripts/right-effects.js +6 -0
- data/javascripts/right-events-src.js +369 -0
- data/javascripts/right-events.js +6 -0
- data/javascripts/right-json-src.js +176 -0
- data/javascripts/right-json.js +6 -0
- data/javascripts/right-lightbox-src.js +597 -0
- data/javascripts/right-lightbox.js +9 -0
- data/javascripts/right-rails-src.js +269 -0
- data/javascripts/right-rails.js +9 -0
- data/javascripts/right-rater-src.js +248 -0
- data/javascripts/right-rater.js +9 -0
- data/javascripts/right-selectable-src.js +507 -0
- data/javascripts/right-selectable.js +7 -0
- data/javascripts/right-slider-src.js +291 -0
- data/javascripts/right-slider.js +7 -0
- data/javascripts/right-sortable-src.js +221 -0
- data/javascripts/right-sortable.js +9 -0
- data/javascripts/right-src.js +4939 -0
- data/javascripts/right-tabs-src.js +776 -0
- data/javascripts/right-tabs.js +6 -0
- data/javascripts/right-tooltips-src.js +130 -0
- data/javascripts/right-tooltips.js +9 -0
- data/javascripts/right-ui-i18n-de.js +29 -0
- data/javascripts/right-ui-i18n-en-us.js +11 -0
- data/javascripts/right-ui-i18n-es.js +29 -0
- data/javascripts/right-ui-i18n-fr.js +29 -0
- data/javascripts/right-ui-i18n-jp.js +33 -0
- data/javascripts/right-ui-i18n-ru.js +29 -0
- data/javascripts/right-ui-i18n-uk.js +29 -0
- data/javascripts/right.js +10 -0
- data/lib/right-rails.rb +11 -0
- data/lib/right_rails/controller_extensions.rb +85 -0
- data/lib/right_rails/helpers/basic.rb +111 -0
- data/lib/right_rails/helpers/forms.rb +239 -0
- data/lib/right_rails/helpers/misc.rb +164 -0
- data/lib/right_rails/helpers/rails.rb +166 -0
- data/lib/right_rails/helpers.rb +5 -0
- data/lib/right_rails/java_script_generator.rb +313 -0
- data/lib/right_rails.rb +6 -0
- data/spec/lib/right_rails/controller_extensions_spec.rb +60 -0
- data/spec/lib/right_rails/helpers/basic_spec.rb +74 -0
- data/spec/lib/right_rails/helpers/forms_spec.rb +51 -0
- data/spec/lib/right_rails/helpers/misc_spec.rb +120 -0
- data/spec/lib/right_rails/helpers/rails_spec.rb +149 -0
- data/spec/lib/right_rails/java_script_generator_spec.rb +317 -0
- data/spec/spec.opts +5 -0
- data/spec/spec_helper.rb +15 -0
- metadata +128 -0
@@ -0,0 +1,149 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../../../spec_helper.rb"
|
2
|
+
|
3
|
+
describe RightRails::Helpers::Rails do
|
4
|
+
include ActionView::Helpers::TagHelper
|
5
|
+
include ActionView::Helpers::JavaScriptHelper
|
6
|
+
include ActionView::Helpers::ScriptaculousHelper
|
7
|
+
include ActionView::Helpers::FormTagHelper
|
8
|
+
include RightRails::Helpers::Basic
|
9
|
+
include RightRails::Helpers::Rails
|
10
|
+
|
11
|
+
# stubbing the convertion methods
|
12
|
+
def url_for(url) url end
|
13
|
+
def protect_against_forgery?() false end
|
14
|
+
|
15
|
+
describe "#remote_function" do
|
16
|
+
it "should generatorate a simple request" do
|
17
|
+
remote_function(:url => '/foo').should == "Xhr.load('/foo')"
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should let you specify the method" do
|
21
|
+
remote_function(:url => '/foo', :method => 'put').should ==
|
22
|
+
"Xhr.load('/foo',{method:'put'})"
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should let you specify the spinners" do
|
26
|
+
remote_function(:url => '/foo', :spinner => 'my-spinner').should ==
|
27
|
+
"Xhr.load('/foo',{spinner:'my-spinner'})"
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should let you specify the callbacks" do
|
31
|
+
remote_function(:url => '/foo', :before => 'before()', :after => 'after()',
|
32
|
+
:complete => 'complete()', :success => 'success()', :failure => 'failure()').should ==
|
33
|
+
"before();Xhr.load('/foo',{"+
|
34
|
+
"onComplete:function(request){complete();},"+
|
35
|
+
"onFailure:function(request){failure();},"+
|
36
|
+
"onSuccess:function(request){success();}});after()"
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should work with the 'with' parameter" do
|
40
|
+
remote_function(:url => '/foo', :with => "'name='+'boo'").should ==
|
41
|
+
"Xhr.load('/foo',{params:'name='+'boo'})"
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should generate an update call" do
|
45
|
+
remote_function(:url => '/foo', :update => 'boo').should ==
|
46
|
+
"Xhr.load('/foo',{onComplete:function(request){$('boo').update(this.text)}})"
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should generate an update for different elements depend on the status" do
|
50
|
+
remote_function(:url => '/foo', :update => {:success => "boo", :failure => "moo"}).should ==
|
51
|
+
"Xhr.load('/foo',{"+
|
52
|
+
"onFailure:function(request){$('moo').update(this.text)},"+
|
53
|
+
"onSuccess:function(request){$('boo').update(this.text)}})"
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should generate update calls with position" do
|
57
|
+
remote_function(:url => '/foo', :update => 'boo', :position => :top).should ==
|
58
|
+
"Xhr.load('/foo',{onComplete:function(request){$('boo').insert(this.text,'top')}})"
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should allow to specify the Xhr options" do
|
62
|
+
remote_function(:url => '/foo', :evalScripts => true, :encoding => 'cp1251', :params => 'boo=boo').should ==
|
63
|
+
"Xhr.load('/foo',{encoding:'cp1251',evalScripts:true,params:'boo=boo'})"
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should allow the 'condition' option" do
|
67
|
+
remote_function(:url => '/foo', :condition => 'boo()').should ==
|
68
|
+
"if(boo()){Xhr.load('/foo')}"
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should allow the 'confirm' option" do
|
72
|
+
remote_function(:url => '/foo', :confirm => 'Sure?').should ==
|
73
|
+
"if(confirm('Sure?')){Xhr.load('/foo')}"
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
describe "#link_to_function" do
|
78
|
+
it "should still be working with string commands" do
|
79
|
+
link_to_function('click me', "$(this).remove()").should ==
|
80
|
+
'<a href="#" onclick="$(this).remove(); return false;">click me</a>'
|
81
|
+
end
|
82
|
+
|
83
|
+
it "should still be working with blocks" do
|
84
|
+
link_to_function('click me') do |page|
|
85
|
+
page.alert 'boo'
|
86
|
+
end.should == '<a href="#" onclick="alert("boo");; return false;">click me</a>'
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe "#button_to_function" do
|
91
|
+
it "should be working with string commands" do
|
92
|
+
button_to_function('Boo', "alert('boo')").should == %Q{<input onclick="alert('boo');" type="button" value="Boo" />}
|
93
|
+
end
|
94
|
+
|
95
|
+
it "should be working with the blocks" do
|
96
|
+
button_to_function('Boo'){|p| p.alert('boo')}.should == %Q{<input onclick="alert("boo");;" type="button" value="Boo" />}
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
describe "#link_to_remote" do
|
101
|
+
it "should generate normal remote calls" do
|
102
|
+
link_to_remote('click me', :url => 'boo').should == %Q{<a href="#" onclick="Xhr.load('boo'); return false;">click me</a>}
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
describe "#button_to_remote" do
|
107
|
+
it "should generate normal remote calls" do
|
108
|
+
button_to_remote('Boo', :url => '/boo').should == %Q{<input onclick="Xhr.load('/boo');" type="button" value="Boo" />}
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
describe "#submit_to_remote" do
|
113
|
+
it "should generate a proper element" do
|
114
|
+
submit_to_remote('name', 'Send', :url => '/foo', :spinner => 'spinner').should ==
|
115
|
+
%Q[<input name="name" onclick="new Xhr('/foo',{spinner:'spinner'}).send($(this.form));" type="button" value="Send" />]
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
describe "#form_remote_tag" do
|
120
|
+
it "should generate a proper remote form" do
|
121
|
+
form_remote_tag(:url => '/boo', :spinner => 'spinner').should ==
|
122
|
+
%Q{<form action="/boo" method="post" onsubmit="$(this).send({spinner:'spinner'}); return false;">}
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
describe "#periodically_call_remote" do
|
127
|
+
it "should generate the script" do
|
128
|
+
periodically_call_remote(:url => '/foo').should ==
|
129
|
+
%Q{<script type=\"text/javascript\">\n//<![CDATA[\nfunction(){Xhr.load('/foo')}.periodical(10000)\n//]]>\n</script>}
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
it "should generate #draggable_element_js" do
|
134
|
+
draggable_element_js(:element_id, :revert => true).should == 'new Draggable("element_id", {revert:true});'
|
135
|
+
@_right_scripts.should == ['dnd']
|
136
|
+
end
|
137
|
+
|
138
|
+
it "should generate #drop_receiving_element_js" do
|
139
|
+
drop_receiving_element_js(:element_id, :url => '/boo').should ==
|
140
|
+
%Q{new Droppable("element_id", {onDrop:function(draggable){Xhr.load('/boo',{params:'id=' + encodeURIComponent(draggable.element.id)})}});}
|
141
|
+
|
142
|
+
@_right_scripts.should == ['dnd']
|
143
|
+
end
|
144
|
+
|
145
|
+
it "should generate #sortable_element_js" do
|
146
|
+
sortable_element_js(:element_id, :url => '/stuff/%{id}.js').should ==
|
147
|
+
%Q{new Sortable('element_id',{url:'/stuff/%{id}.js'})}
|
148
|
+
end
|
149
|
+
end
|
@@ -0,0 +1,317 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../../spec_helper.rb"
|
2
|
+
|
3
|
+
#
|
4
|
+
# Fake active-record and active resource classes to work with
|
5
|
+
#
|
6
|
+
module ActiveRecord
|
7
|
+
class Base
|
8
|
+
def initialize(hash={})
|
9
|
+
@hash = hash
|
10
|
+
end
|
11
|
+
|
12
|
+
def id
|
13
|
+
@hash[:id]
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.table_name
|
17
|
+
name = 'records'
|
18
|
+
name.stub!(:singularize).and_return('record')
|
19
|
+
name
|
20
|
+
end
|
21
|
+
|
22
|
+
def new_record?
|
23
|
+
true
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
module ActiveResource
|
29
|
+
class Base
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe RightRails::JavaScriptGenerator do
|
34
|
+
before :each do
|
35
|
+
@template = mock()
|
36
|
+
def @template.dom_id(record) "record_#{record.id}" end
|
37
|
+
def @template.escape_javascript(str) str end
|
38
|
+
|
39
|
+
@page = RightRails::JavaScriptGenerator.new(@template)
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "top level calls" do
|
43
|
+
it "should generate a simple ID search" do
|
44
|
+
@page['element-id']
|
45
|
+
@page.to_s.should == '$("element-id");'
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should respond to the top-level javascript objects" do
|
49
|
+
@page.document
|
50
|
+
@page.to_s.should == 'document;'
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should generate an ID search from active-records and active-resources" do
|
54
|
+
@record = ActiveRecord::Base.new({:id => '22'})
|
55
|
+
@page[@record]
|
56
|
+
@page.to_s.should == '$("record_22");'
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should generate a CSS select block" do
|
60
|
+
@page.find('div, span, table')
|
61
|
+
@page.to_s.should == '$$("div, span, table");'
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should generate redirect" do
|
65
|
+
@page.redirect_to('/boo/boo/boo')
|
66
|
+
@page.to_s.should == 'document.location.href="/boo/boo/boo";'
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should generate reload" do
|
70
|
+
@page.reload
|
71
|
+
@page.to_s.should == 'document.location.reload();'
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should process assignments" do
|
75
|
+
@page.something = nil;
|
76
|
+
@page.to_s.should == 'something=null;'
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should provide access to javascript context variables" do
|
80
|
+
@page.get(:my_var).property = 'boo';
|
81
|
+
@page.to_s.should == 'my_var.property="boo";'
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should let you set the variables" do
|
85
|
+
@page.set(:my_var, nil)
|
86
|
+
@page.to_s.should == 'var my_var=null;'
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should process << pushes correctly" do
|
90
|
+
@page << 'some_code();' << 'another_code();'
|
91
|
+
@page.to_s.should == 'some_code();another_code();'
|
92
|
+
end
|
93
|
+
|
94
|
+
it "should convert several lines of code properly" do
|
95
|
+
@page['el1'].update('text1').show();
|
96
|
+
@page['el2'].update('text2').highlight();
|
97
|
+
|
98
|
+
@page.to_s.should == '$("el1").update("text1").show();$("el2").update("text2").highlight();'
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
describe "second level calls" do
|
103
|
+
it "should catch up an element method simple calls" do
|
104
|
+
@page['element-id'].myMethod
|
105
|
+
@page.to_s.should == '$("element-id").myMethod();'
|
106
|
+
end
|
107
|
+
|
108
|
+
it "should catch up an element method arguments as well" do
|
109
|
+
@page['element-id'].myMethod(1,2,3)
|
110
|
+
@page.to_s.should == '$("element-id").myMethod(1,2,3);'
|
111
|
+
end
|
112
|
+
|
113
|
+
it "should catch up with element property calls" do
|
114
|
+
@page['element-id'][:innerHTML]
|
115
|
+
@page.to_s.should == '$("element-id").innerHTML;'
|
116
|
+
end
|
117
|
+
|
118
|
+
it "should catch up with element properties call chains" do
|
119
|
+
@page['element-id'].test(1).show.highlight()
|
120
|
+
@page.to_s.should == '$("element-id").test(1).show().highlight();'
|
121
|
+
end
|
122
|
+
|
123
|
+
it "should catch up the assignments correctly" do
|
124
|
+
@page['element-id'].innerHTML = nil;
|
125
|
+
@page.to_s.should == '$("element-id").innerHTML=null;'
|
126
|
+
end
|
127
|
+
|
128
|
+
it "should catch the property assignment calls too" do
|
129
|
+
@page['element-id'][:title] = 'something';
|
130
|
+
@page.to_s.should == '$("element-id").title="something";'
|
131
|
+
end
|
132
|
+
|
133
|
+
it "should process other methods calls as arguments" do
|
134
|
+
@page['element-id'].update(@page.my_method(@page.another_method(1,2),3,nil))
|
135
|
+
@page.to_s.should == '$("element-id").update(my_method(another_method(1,2),3,null));'
|
136
|
+
end
|
137
|
+
|
138
|
+
it "should process operation calls" do
|
139
|
+
@page.property = @page.first + @page.another(1,nil) * @page.more / 2 -
|
140
|
+
@page.get(:thing) / @page.another(2) + nil - 'boo' + @page.last(@page.first)
|
141
|
+
|
142
|
+
@page.to_s.should == 'property=first()+another(1,null)*more()/2-thing/another(2)+null-"boo"+last(first());'
|
143
|
+
end
|
144
|
+
|
145
|
+
it "should process the append operation" do
|
146
|
+
@page['element'][:innerHTML] << 'boo'
|
147
|
+
@page.to_s.should == '$("element").innerHTML+="boo";'
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
describe "data types conversion" do
|
152
|
+
it "should correctly process numeric arguments" do
|
153
|
+
@page['element-id'].test(1, 2.3)
|
154
|
+
@page.to_s.should == '$("element-id").test(1,2.3);'
|
155
|
+
end
|
156
|
+
|
157
|
+
it "should correctly process boolean and nil values" do
|
158
|
+
@page["element-id"].test(true, false, nil)
|
159
|
+
@page.to_s.should == '$("element-id").test(true,false,null);'
|
160
|
+
end
|
161
|
+
|
162
|
+
it "should escape string arguments properly" do
|
163
|
+
@template.should_receive(:escape_javascript).with('"quoted"').and_return('_quoted_')
|
164
|
+
@page["element-id"].test('"quoted"')
|
165
|
+
@page.to_s.should == '$("element-id").test("_quoted_");'
|
166
|
+
end
|
167
|
+
|
168
|
+
it "should convert symbols into object reverences" do
|
169
|
+
@page["element-id"].test(:name1, :name2, :name3)
|
170
|
+
@page.to_s.should == '$("element-id").test(name1,name2,name3);'
|
171
|
+
end
|
172
|
+
|
173
|
+
it "should handle arrays properly" do
|
174
|
+
@template.should_receive(:escape_javascript).with('"quoted"').and_return('_quoted_')
|
175
|
+
|
176
|
+
@page["element-id"].test([1,2.3,[nil,[true,'"quoted"']]])
|
177
|
+
@page.to_s.should == '$("element-id").test([1,2.3,[null,[true,"_quoted_"]]]);'
|
178
|
+
end
|
179
|
+
|
180
|
+
it "should handle hashes properly" do
|
181
|
+
@page["element-id"].test({
|
182
|
+
:one => 1,
|
183
|
+
:two => 2.3,
|
184
|
+
'four' => {
|
185
|
+
'five' => true,
|
186
|
+
'six' => nil
|
187
|
+
}
|
188
|
+
})
|
189
|
+
@page.to_s.should == '$("element-id").test({"four":{"five":true,"six":null},one:1,two:2.3});'
|
190
|
+
end
|
191
|
+
|
192
|
+
it "should handle JSON exportable units too" do
|
193
|
+
@value = ActiveRecord::Base.new({:id => '22'});
|
194
|
+
def @value.to_json
|
195
|
+
{:id => id}
|
196
|
+
end
|
197
|
+
|
198
|
+
@page["element-id"].test(@value)
|
199
|
+
@page.to_s.should == '$("element-id").test({id:"22"});'
|
200
|
+
end
|
201
|
+
|
202
|
+
it "should convert lambdas to functions" do
|
203
|
+
@page.find("boo").each(lambda{ |item, i, array|
|
204
|
+
item.boo(i.foo(2)) + array.hoo
|
205
|
+
})
|
206
|
+
@page.to_s.should == '$$("boo").each(function(a,b,c){a.boo(b.foo(2))+c.hoo();});'
|
207
|
+
end
|
208
|
+
|
209
|
+
it "should process blocks nicely" do
|
210
|
+
@page.find("boo").each do |item, i|
|
211
|
+
item.boo(i.foo('hoo'))
|
212
|
+
end
|
213
|
+
|
214
|
+
@page.to_s.should == '$$("boo").each(function(a,b){a.boo(b.foo("hoo"));});'
|
215
|
+
end
|
216
|
+
|
217
|
+
it "should process blocks with scope variables and the page builder calls" do
|
218
|
+
some_text = 'boo'
|
219
|
+
|
220
|
+
@page.find("foo").each do |item, index|
|
221
|
+
@page['element'][:innerHTML] << item[:innerHTML] + index + some_text
|
222
|
+
end
|
223
|
+
|
224
|
+
# checking that the context is getting back
|
225
|
+
@page.alert(@page['element'][:innerHTML])
|
226
|
+
|
227
|
+
@page.to_s.should == '$$("foo").each(function(a,b){$("element").innerHTML+=a.innerHTML+b+"boo";});alert($("element").innerHTML);'
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
describe "RR object method calls generator" do
|
232
|
+
before :each do
|
233
|
+
@record = ActiveRecord::Base.new({:id => '22'})
|
234
|
+
end
|
235
|
+
|
236
|
+
it "should generate script for the 'insert' request" do
|
237
|
+
@template.should_receive(:render).with(@record).and_return('<record html code/>')
|
238
|
+
|
239
|
+
@page.insert(@record)
|
240
|
+
@page.to_s.should == 'RR.insert("records","<record html code/>");'
|
241
|
+
end
|
242
|
+
|
243
|
+
it "should generate script for the 'replace' request" do
|
244
|
+
@template.should_receive(:render).with(@record).and_return('<record html code/>')
|
245
|
+
|
246
|
+
@page.replace(@record)
|
247
|
+
@page.to_s.should == 'RR.replace("record_22","<record html code/>");'
|
248
|
+
end
|
249
|
+
|
250
|
+
it "should generate script for the 'remove' request" do
|
251
|
+
@page.remove(@record)
|
252
|
+
@page.to_s.should == 'RR.remove("record_22");'
|
253
|
+
end
|
254
|
+
|
255
|
+
it "should generate script for the 'show_form_for' request" do
|
256
|
+
@template.should_receive(:render).with('form').and_return('<the form html code/>')
|
257
|
+
|
258
|
+
@page.show_form_for(@record)
|
259
|
+
@page.to_s.should == 'RR.show_form_for("record_22","<the form html code/>");'
|
260
|
+
end
|
261
|
+
|
262
|
+
describe "replace_form_for generator" do
|
263
|
+
before :each do
|
264
|
+
@template.should_receive(:render).with('form').and_return('<the form html code/>')
|
265
|
+
end
|
266
|
+
|
267
|
+
it "should generate a script for a new record" do
|
268
|
+
@record.should_receive(:new_record?).and_return(true)
|
269
|
+
|
270
|
+
@page.replace_form_for(@record)
|
271
|
+
@page.to_s.should == 'RR.replace_form("new_record","<the form html code/>");'
|
272
|
+
end
|
273
|
+
|
274
|
+
it "should generate a script for an existing record" do
|
275
|
+
@record.should_receive(:new_record?).and_return(false)
|
276
|
+
|
277
|
+
@page.replace_form_for(@record)
|
278
|
+
@page.to_s.should == 'RR.replace_form("edit_record_22","<the form html code/>");'
|
279
|
+
end
|
280
|
+
end
|
281
|
+
|
282
|
+
describe "updates with care" do
|
283
|
+
before :each do
|
284
|
+
@template.should_receive(:flashes).and_return('<flashes/>')
|
285
|
+
@template.should_receive(:flash).and_return(mock(:flash, {:clear => true}))
|
286
|
+
end
|
287
|
+
|
288
|
+
it "should generate response for #update_flash" do
|
289
|
+
@page.update_flash
|
290
|
+
@page.to_s.should == 'RR.update_flash("<flashes/>");'
|
291
|
+
end
|
292
|
+
|
293
|
+
it "should generate response for the #insert_and_care method" do
|
294
|
+
@template.should_receive(:render).with('form').and_return('<the form html code/>')
|
295
|
+
@template.should_receive(:render).with(@record).and_return('<record html code/>')
|
296
|
+
|
297
|
+
@page.insert_and_care(@record)
|
298
|
+
|
299
|
+
@page.to_s.should == 'RR.insert("records","<record html code/>");' +
|
300
|
+
'RR.replace_form("new_record","<the form html code/>");' +
|
301
|
+
'RR.update_flash("<flashes/>");'
|
302
|
+
end
|
303
|
+
|
304
|
+
it "should generate response for the #replace_and_care method" do
|
305
|
+
@template.should_receive(:render).with(@record).and_return('<record html code/>')
|
306
|
+
|
307
|
+
@page.replace_and_care(@record)
|
308
|
+
|
309
|
+
@page.to_s.should == 'RR.replace("record_22","<record html code/>");' +
|
310
|
+
'RR.update_flash("<flashes/>");'
|
311
|
+
end
|
312
|
+
end
|
313
|
+
|
314
|
+
end
|
315
|
+
|
316
|
+
|
317
|
+
end
|
data/spec/spec.opts
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec'
|
2
|
+
|
3
|
+
$LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
|
4
|
+
|
5
|
+
require 'action_view'
|
6
|
+
require 'action_controller'
|
7
|
+
|
8
|
+
require 'right_rails'
|
9
|
+
require 'right_rails/java_script_generator'
|
10
|
+
require 'right_rails/controller_extensions'
|
11
|
+
require 'right_rails/helpers'
|
12
|
+
require 'right_rails/helpers/basic'
|
13
|
+
require 'right_rails/helpers/rails'
|
14
|
+
require 'right_rails/helpers/forms'
|
15
|
+
require 'right_rails/helpers/misc'
|
metadata
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: right-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nikolay Nemshilov
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-11-22 00:00:00 +03:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: RightRails provides support of the RightJS framework for the native Rails/Prototype helpers, plus it has a new RJS processor, most common ajax operations interface, RightJS own feature support, remove files uploading handler, etc.
|
17
|
+
email: nemshilov@gmail.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files: []
|
23
|
+
|
24
|
+
files:
|
25
|
+
- generators/right_rails/right_rails_generator.rb
|
26
|
+
- generators/right_rails/templates/iframed.html.erb
|
27
|
+
- generators/right_scaffold/right_scaffold_generator.rb
|
28
|
+
- generators/right_scaffold/templates/controller.rb
|
29
|
+
- generators/right_scaffold/templates/helper.rb
|
30
|
+
- generators/right_scaffold/templates/layout.html.erb
|
31
|
+
- generators/right_scaffold/templates/style.css
|
32
|
+
- generators/right_scaffold/templates/view__form.html.erb
|
33
|
+
- generators/right_scaffold/templates/view__item.html.erb
|
34
|
+
- generators/right_scaffold/templates/view_edit.html.erb
|
35
|
+
- generators/right_scaffold/templates/view_index.html.erb
|
36
|
+
- generators/right_scaffold/templates/view_new.html.erb
|
37
|
+
- generators/right_scaffold/templates/view_show.html.erb
|
38
|
+
- javascripts/right-autocompleter-src.js
|
39
|
+
- javascripts/right-autocompleter.js
|
40
|
+
- javascripts/right-behavior-src.js
|
41
|
+
- javascripts/right-behavior.js
|
42
|
+
- javascripts/right-calendar-src.js
|
43
|
+
- javascripts/right-calendar.js
|
44
|
+
- javascripts/right-dnd-src.js
|
45
|
+
- javascripts/right-dnd.js
|
46
|
+
- javascripts/right-effects-src.js
|
47
|
+
- javascripts/right-effects.js
|
48
|
+
- javascripts/right-events-src.js
|
49
|
+
- javascripts/right-events.js
|
50
|
+
- javascripts/right-json-src.js
|
51
|
+
- javascripts/right-json.js
|
52
|
+
- javascripts/right-lightbox-src.js
|
53
|
+
- javascripts/right-lightbox.js
|
54
|
+
- javascripts/right-rails-src.js
|
55
|
+
- javascripts/right-rails.js
|
56
|
+
- javascripts/right-rater-src.js
|
57
|
+
- javascripts/right-rater.js
|
58
|
+
- javascripts/right-selectable-src.js
|
59
|
+
- javascripts/right-selectable.js
|
60
|
+
- javascripts/right-slider-src.js
|
61
|
+
- javascripts/right-slider.js
|
62
|
+
- javascripts/right-sortable-src.js
|
63
|
+
- javascripts/right-sortable.js
|
64
|
+
- javascripts/right-src.js
|
65
|
+
- javascripts/right-tabs-src.js
|
66
|
+
- javascripts/right-tabs.js
|
67
|
+
- javascripts/right-tooltips-src.js
|
68
|
+
- javascripts/right-tooltips.js
|
69
|
+
- javascripts/right-ui-i18n-de.js
|
70
|
+
- javascripts/right-ui-i18n-en-us.js
|
71
|
+
- javascripts/right-ui-i18n-es.js
|
72
|
+
- javascripts/right-ui-i18n-fr.js
|
73
|
+
- javascripts/right-ui-i18n-jp.js
|
74
|
+
- javascripts/right-ui-i18n-ru.js
|
75
|
+
- javascripts/right-ui-i18n-uk.js
|
76
|
+
- javascripts/right.js
|
77
|
+
- lib/right-rails.rb
|
78
|
+
- lib/right_rails/controller_extensions.rb
|
79
|
+
- lib/right_rails/helpers/basic.rb
|
80
|
+
- lib/right_rails/helpers/forms.rb
|
81
|
+
- lib/right_rails/helpers/misc.rb
|
82
|
+
- lib/right_rails/helpers/rails.rb
|
83
|
+
- lib/right_rails/helpers.rb
|
84
|
+
- lib/right_rails/java_script_generator.rb
|
85
|
+
- lib/right_rails.rb
|
86
|
+
- spec/lib/right_rails/controller_extensions_spec.rb
|
87
|
+
- spec/lib/right_rails/helpers/basic_spec.rb
|
88
|
+
- spec/lib/right_rails/helpers/forms_spec.rb
|
89
|
+
- spec/lib/right_rails/helpers/misc_spec.rb
|
90
|
+
- spec/lib/right_rails/helpers/rails_spec.rb
|
91
|
+
- spec/lib/right_rails/java_script_generator_spec.rb
|
92
|
+
- spec/spec.opts
|
93
|
+
- spec/spec_helper.rb
|
94
|
+
- README.textile
|
95
|
+
- MIT-LICENSE
|
96
|
+
- Rakefile
|
97
|
+
- init.rb
|
98
|
+
has_rdoc: true
|
99
|
+
homepage: http://github.com/MadRabbit/right-rails
|
100
|
+
licenses: []
|
101
|
+
|
102
|
+
post_install_message: "\n\
|
103
|
+
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< RIGHT RAILS >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n\n Please run the following command to copy RightJS scripts and modules in place\n \n script/generate right_rails\n\n Cheers!\n \n "
|
104
|
+
rdoc_options: []
|
105
|
+
|
106
|
+
require_paths:
|
107
|
+
- lib
|
108
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: "0"
|
113
|
+
version:
|
114
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: "0"
|
119
|
+
version:
|
120
|
+
requirements: []
|
121
|
+
|
122
|
+
rubyforge_project:
|
123
|
+
rubygems_version: 1.3.5
|
124
|
+
signing_key:
|
125
|
+
specification_version: 3
|
126
|
+
summary: RightJS plugin for Rails
|
127
|
+
test_files: []
|
128
|
+
|