right-rails 1.0.3 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. data/CHANGELOG +8 -2
  2. data/Rakefile +28 -28
  3. data/lib/right_rails/java_script_generator.rb +59 -51
  4. data/public/images/{colorpicker.png → rightjs-ui/colorpicker.png} +0 -0
  5. data/public/images/{resizable.png → rightjs-ui/resizable.png} +0 -0
  6. data/public/javascripts/right-olds-src.js +47 -46
  7. data/public/javascripts/right-safe-src.js +103 -102
  8. data/public/javascripts/right-safe.js +1 -1
  9. data/public/javascripts/right-src.js +611 -541
  10. data/public/javascripts/right.js +86 -85
  11. data/public/javascripts/right/autocompleter-src.js +81 -77
  12. data/public/javascripts/right/autocompleter.js +1 -1
  13. data/public/javascripts/right/calendar-src.js +209 -197
  14. data/public/javascripts/right/calendar.js +6 -6
  15. data/public/javascripts/right/colorpicker-src.js +127 -117
  16. data/public/javascripts/right/colorpicker.js +6 -6
  17. data/public/javascripts/right/dnd-src.js +63 -63
  18. data/public/javascripts/right/dnd.js +2 -2
  19. data/public/javascripts/right/in-edit-src.js +53 -48
  20. data/public/javascripts/right/in-edit.js +2 -2
  21. data/public/javascripts/right/lightbox-src.js +107 -99
  22. data/public/javascripts/right/lightbox.js +2 -2
  23. data/public/javascripts/right/rater-src.js +48 -46
  24. data/public/javascripts/right/rater.js +3 -3
  25. data/public/javascripts/right/resizable-src.js +53 -61
  26. data/public/javascripts/right/resizable.js +4 -4
  27. data/public/javascripts/right/selectable-src.js +97 -95
  28. data/public/javascripts/right/selectable.js +2 -2
  29. data/public/javascripts/right/slider-src.js +47 -45
  30. data/public/javascripts/right/slider.js +8 -8
  31. data/public/javascripts/right/sortable-src.js +54 -52
  32. data/public/javascripts/right/tabs-src.js +181 -171
  33. data/public/javascripts/right/tooltip-src.js +39 -37
  34. data/public/javascripts/right/uploader-src.js +21 -19
  35. data/spec/lib/right_rails/java_script_generator_spec.rb +61 -56
  36. metadata +9 -7
@@ -33,13 +33,13 @@ var R = RightJS,
33
33
  * @param String tag-name or Object methods
34
34
  * @param Object methods
35
35
  * @return Widget wrapper
36
- */
36
+ */
37
37
  function Widget(tag_name, methods) {
38
38
  if (!methods) {
39
39
  methods = tag_name;
40
40
  tag_name = 'DIV';
41
41
  }
42
-
42
+
43
43
  /**
44
44
  * An Abstract Widget Unit
45
45
  *
@@ -56,17 +56,17 @@ function Widget(tag_name, methods) {
56
56
  initialize: function(key, options) {
57
57
  this.key = key;
58
58
  var args = [{'class': 'rui-' + key}];
59
-
59
+
60
60
  // those two have different constructors
61
61
  if (!(this instanceof RightJS.Input || this instanceof RightJS.Form)) {
62
62
  args.unshift(tag_name);
63
63
  }
64
64
  this.$super.apply(this, args);
65
-
65
+
66
66
  if (RightJS.isString(options)) {
67
67
  options = RightJS.$(options);
68
68
  }
69
-
69
+
70
70
  // if the options is another element then
71
71
  // try to dynamically rewrap it with our widget
72
72
  if (options instanceof RightJS.Element) {
@@ -99,16 +99,16 @@ function Widget(tag_name, methods) {
99
99
  return this;
100
100
  }
101
101
  });
102
-
102
+
103
103
  /**
104
104
  * Creating the actual widget class
105
105
  *
106
106
  */
107
107
  var Klass = new RightJS.Wrapper(AbstractWidget, methods);
108
-
108
+
109
109
  // creating the widget related shortcuts
110
110
  RightJS.Observer.createShortcuts(Klass.prototype, Klass.EVENTS || []);
111
-
111
+
112
112
  return Klass;
113
113
  }
114
114
 
@@ -121,35 +121,35 @@ function Widget(tag_name, methods) {
121
121
  var Tooltip = new Widget({
122
122
  extend: {
123
123
  version: '2.0.0',
124
-
124
+
125
125
  EVENTS: $w('show hide'),
126
-
126
+
127
127
  Options: {
128
128
  cssRule: '[data-tooltip]', // a css-marker of an element with a tooltip
129
-
129
+
130
130
  fxName: 'fade', // the appearance effect name
131
131
  fxDuration: 400, // the appearance effect duration
132
132
  delay: 400, // the appearance delay
133
-
133
+
134
134
  move: true, // if it should be moved with the mouse
135
-
135
+
136
136
  idSuffix: '-tooltip' // ID prefix for tooltips with ID
137
137
  },
138
-
138
+
139
139
  current: null, // the currently active tooltip reference
140
140
  instances: R([]), // keeps the list of instances
141
-
141
+
142
142
  // tries to find a tip closest to the event
143
143
  find: function(event) {
144
144
  var element = event.find(Tooltip.Options.cssRule);
145
-
145
+
146
146
  if (element) {
147
147
  var uid = $uid(element);
148
148
  return (Tooltip.instances[uid] || (Tooltip.instances[uid] = new Tooltip(element)));
149
149
  }
150
150
  }
151
151
  },
152
-
152
+
153
153
  /**
154
154
  * Constructor
155
155
  *
@@ -158,7 +158,7 @@ var Tooltip = new Widget({
158
158
  */
159
159
  initialize: function(element, options) {
160
160
  this.associate = element = $(element);
161
-
161
+
162
162
  this
163
163
  .$super('tooltip')
164
164
  .setOptions(options, element)
@@ -172,16 +172,16 @@ var Tooltip = new Widget({
172
172
  mouseover: this._cancelTimer
173
173
  })
174
174
  .insertTo(document.body);
175
-
175
+
176
176
  // adding the ID if needed
177
177
  if (element.has('id')) {
178
178
  this.set('id', element.get('id') + this.options.idSuffix);
179
179
  }
180
-
180
+
181
181
  // removing the titles from the elment
182
182
  element.set({ title: '', alt: ''});
183
183
  },
184
-
184
+
185
185
  /**
186
186
  * Hides the tooltip
187
187
  *
@@ -189,7 +189,7 @@ var Tooltip = new Widget({
189
189
  */
190
190
  hide: function() {
191
191
  this._cancelTimer();
192
-
192
+
193
193
  this._timer = R(function() {
194
194
  Element.prototype.hide.call(this, this.options.fxName, {
195
195
  duration: this.options.fxDuration,
@@ -201,10 +201,10 @@ var Tooltip = new Widget({
201
201
  });
202
202
  this.fire('hide');
203
203
  }).bind(this).delay(100);
204
-
204
+
205
205
  return this;
206
206
  },
207
-
207
+
208
208
  /**
209
209
  * Shows the tooltip with a dealy
210
210
  *
@@ -216,19 +216,19 @@ var Tooltip = new Widget({
216
216
  Tooltip.instances.each(function(tip) {
217
217
  if (tip && tip !== this) { tip.hide(); }
218
218
  }, this);
219
-
219
+
220
220
  // show the tooltip with a delay
221
221
  this._timer = R(function() {
222
222
  Element.prototype.show.call(this.stop(),
223
223
  this.options.fxName, {duration: this.options.fxDuration}
224
224
  );
225
-
225
+
226
226
  Tooltip.current = this.fire('show');
227
227
  }).bind(this).delay(this.options.delay);
228
-
228
+
229
229
  return (Tooltip.current = this);
230
230
  },
231
-
231
+
232
232
  /**
233
233
  * Moves it to where the event happened
234
234
  *
@@ -237,22 +237,23 @@ var Tooltip = new Widget({
237
237
  moveToEvent: function(event) {
238
238
  this._.style.left = event.pageX + 'px';
239
239
  this._.style.top = event.pageY + 'px';
240
-
240
+
241
241
  return this;
242
242
  },
243
-
243
+
244
244
  // protected
245
-
245
+
246
246
  // cancels a show timeout
247
247
  _cancelTimer: function(event) {
248
248
  if (event) { event.stop(); }
249
249
  if (this._timer) {
250
- this._timer.cancel();
250
+ this._timer.cancel();
251
251
  this._timer = null;
252
252
  }
253
253
  }
254
254
  });
255
255
 
256
+
256
257
  /**
257
258
  * The post load tooltips initialization script
258
259
  *
@@ -270,11 +271,11 @@ $(document).on({
270
271
  if (this_tip) {
271
272
  if (prev_tip && prev_tip !== this_tip) { prev_tip.hide(); }
272
273
  if (this_tip.hidden()) { this_tip.show(); }
273
-
274
+
274
275
  this_tip.moveToEvent(event);
275
276
  }
276
277
  },
277
-
278
+
278
279
  /**
279
280
  * Catches the mouseout events and hides tooltips when needed
280
281
  *
@@ -282,12 +283,12 @@ $(document).on({
282
283
  */
283
284
  mouseout: function(event) {
284
285
  var curr_tip = Tooltip.current, this_tip = Tooltip.find(event);
285
-
286
+
286
287
  if (curr_tip && (!this_tip || this_tip === curr_tip)) {
287
288
  curr_tip.hide();
288
289
  }
289
290
  },
290
-
291
+
291
292
  /**
292
293
  * Moves tooltips when active
293
294
  *
@@ -301,7 +302,8 @@ $(document).on({
301
302
  }
302
303
  });
303
304
 
305
+
304
306
  document.write("<style type=\"text/css\">div.rui-tooltip{display:none;position:absolute;z-index:99999;font-size:90%;margin-top:16pt;margin-left:5pt;color:#FFF;text-shadow:0 0 .2em #000;border:.3em solid rgba(255,255,255,0.2);background-color:rgba(25,25,25,0.92); *background-color:#000; *border:.3em solid #444;background-image:-webkit-gradient(linear,0% 0%,0% 100%,from(transparent) ,to(#000) );border-radius:.4em;-moz-border-radius:.4em;-webkit-border-radius:.4em;box-shadow:0 0 .4em #555;-moz-box-shadow:0 0 .4em #555;-webkit-box-shadow:0 0 .4em #555}div.rui-tooltip-container{margin:.4em .6em}</style>");
305
307
 
306
308
  return Tooltip;
307
- })(document, RightJS);
309
+ })(document, RightJS);
@@ -37,13 +37,13 @@ var R = RightJS,
37
37
  * @param String tag-name or Object methods
38
38
  * @param Object methods
39
39
  * @return Widget wrapper
40
- */
40
+ */
41
41
  function Widget(tag_name, methods) {
42
42
  if (!methods) {
43
43
  methods = tag_name;
44
44
  tag_name = 'DIV';
45
45
  }
46
-
46
+
47
47
  /**
48
48
  * An Abstract Widget Unit
49
49
  *
@@ -60,17 +60,17 @@ function Widget(tag_name, methods) {
60
60
  initialize: function(key, options) {
61
61
  this.key = key;
62
62
  var args = [{'class': 'rui-' + key}];
63
-
63
+
64
64
  // those two have different constructors
65
65
  if (!(this instanceof RightJS.Input || this instanceof RightJS.Form)) {
66
66
  args.unshift(tag_name);
67
67
  }
68
68
  this.$super.apply(this, args);
69
-
69
+
70
70
  if (RightJS.isString(options)) {
71
71
  options = RightJS.$(options);
72
72
  }
73
-
73
+
74
74
  // if the options is another element then
75
75
  // try to dynamically rewrap it with our widget
76
76
  if (options instanceof RightJS.Element) {
@@ -103,16 +103,16 @@ function Widget(tag_name, methods) {
103
103
  return this;
104
104
  }
105
105
  });
106
-
106
+
107
107
  /**
108
108
  * Creating the actual widget class
109
109
  *
110
110
  */
111
111
  var Klass = new RightJS.Wrapper(AbstractWidget, methods);
112
-
112
+
113
113
  // creating the widget related shortcuts
114
114
  RightJS.Observer.createShortcuts(Klass.prototype, Klass.EVENTS || []);
115
-
115
+
116
116
  return Klass;
117
117
  }
118
118
 
@@ -125,7 +125,7 @@ function Widget(tag_name, methods) {
125
125
  var Uploader = new Widget({
126
126
  extend: {
127
127
  version: '2.0.0',
128
-
128
+
129
129
  EVENTS: $w('start update finish error'),
130
130
 
131
131
  Options: {
@@ -148,7 +148,7 @@ var Uploader = new Widget({
148
148
  */
149
149
  initialize: function(form, options) {
150
150
  this.form = form = $(form);
151
-
151
+
152
152
  // trying to find an existing progress-bar
153
153
  var element = form.first('.rui-uploader');
154
154
 
@@ -160,7 +160,7 @@ var Uploader = new Widget({
160
160
  this.bar = this.first('.bar') || $E('div', {'class': 'bar'}),
161
161
  this.num = this.first('.num') || $E('div', {'class': 'num'})
162
162
  ]);
163
-
163
+
164
164
  if (!element) {
165
165
  this.insertTo(form);
166
166
  }
@@ -209,7 +209,7 @@ var Uploader = new Widget({
209
209
  }
210
210
 
211
211
  this.percent = R(percent * 100).round(this.options.round);
212
-
212
+
213
213
  if (this.percent === 0 || !RightJS.Fx || !this.options.fxDuration) {
214
214
  this.bar._.style.width = this.percent + '%';
215
215
  this.num._.innerHTML = this.percent + '%';
@@ -242,18 +242,19 @@ var Uploader = new Widget({
242
242
  prepare: function() {
243
243
  this.uid = "";
244
244
  for (i = 0; i < 32; i++) { this.uid += Math.random(0, 15).toString(16); }
245
-
245
+
246
246
  var param = this.options.param;
247
247
  var url = this.form.get('action').replace(new RegExp('(\\?|&)'+RegExp.escape(param) + '=[^&]*', 'i'), '');
248
248
  this.form.set('action', (R(url).includes('?') ? '&' : '?') + param + '=' + this.uid);
249
-
249
+
250
250
  this.show();
251
-
251
+
252
252
  return this;
253
253
  }
254
254
 
255
255
  });
256
256
 
257
+
257
258
  /**
258
259
  * Overloading the Form#send method so we could
259
260
  * catch up the moment when a form was sent and show the bar
@@ -264,20 +265,21 @@ var old_send = Form.prototype.send;
264
265
 
265
266
  Form.include({
266
267
  send: function() {
267
-
268
+
268
269
  if (!this.uploader && (this.match(Uploader.Options.cssRule) || this.first('.rui-uploader'))) {
269
270
  this.uploader = new Uploader(this);
270
271
  }
271
-
272
+
272
273
  if (this.uploader) {
273
274
  this.uploader.start();
274
275
  }
275
-
276
+
276
277
  return old_send.apply(this, arguments);
277
278
  }
278
279
  });
279
280
 
281
+
280
282
  document.write("<style type=\"text/css\">div.rui-progress-bar,div.rui-progress-bar *{margin:0;padding:0;border:none;background:none}div.rui-progress-bar{position:relative;height:1.4em;line-height:1.4em;width:20em;border:1px solid #999}div.rui-progress-bar,div.rui-progress-bar div.bar{border-radius:0.25em;-moz-border-radius:0.25em;-webkit-border-radius:0.25em}div.rui-progress-bar div.bar{position:absolute;left:0;top:0;width:0%;height:100%;background:#CCC;z-index:1}div.rui-progress-bar div.num{position:absolute;width:100%;height:100%;z-index:2;text-align:center}div.rui-progress-bar-failed{border-color:red;color:red;background:pink}.rui-uploader{display:none}</style>");
281
283
 
282
284
  return Uploader;
283
- })(RightJS);
285
+ })(RightJS);
@@ -8,17 +8,17 @@ module ActiveRecord
8
8
  def initialize(hash={})
9
9
  @hash = hash
10
10
  end
11
-
11
+
12
12
  def id
13
13
  @hash[:id]
14
14
  end
15
-
15
+
16
16
  def self.table_name
17
17
  name = 'records'
18
18
  name.stub!(:singularize).and_return('record')
19
19
  name
20
20
  end
21
-
21
+
22
22
  def new_record?
23
23
  true
24
24
  end
@@ -33,23 +33,28 @@ end
33
33
  describe RightRails::JavaScriptGenerator do
34
34
  before :each do
35
35
  RightRails::Config.reset!
36
-
36
+
37
37
  @template = mock()
38
38
  def @template.dom_id(record) "record_#{record.id}" end
39
39
  def @template.escape_javascript(str) str end
40
-
40
+
41
41
  @page = RightRails::JavaScriptGenerator.new(@template)
42
42
  end
43
-
43
+
44
44
  describe "top level calls" do
45
45
  it "should generate a simple ID search" do
46
46
  @page['element-id']
47
47
  @page.to_s.should == '$("element-id");'
48
48
  end
49
-
49
+
50
50
  it "should respond to the top-level javascript objects" do
51
51
  @page.document
52
- @page.to_s.should == 'document;'
52
+ @page.to_s.should == '$(document);'
53
+ end
54
+
55
+ it "should generate a normal window access" do
56
+ @page.window
57
+ @page.to_s.should == '$(window);'
53
58
  end
54
59
 
55
60
  it "should generate an ID search from active-records and active-resources" do
@@ -57,66 +62,66 @@ describe RightRails::JavaScriptGenerator do
57
62
  @page[@record]
58
63
  @page.to_s.should == '$("record_22");'
59
64
  end
60
-
65
+
61
66
  it "should generate a CSS select block" do
62
67
  @page.find('div, span, table')
63
68
  @page.to_s.should == '$$("div, span, table");'
64
69
  end
65
-
70
+
66
71
  it "should generate redirect" do
67
72
  @page.redirect_to('/boo/boo/boo')
68
73
  @page.to_s.should == 'document.location.href="/boo/boo/boo";'
69
74
  end
70
-
75
+
71
76
  it "should generate reload" do
72
77
  @page.reload
73
78
  @page.to_s.should == 'document.location.reload();'
74
79
  end
75
-
80
+
76
81
  it "should process assignments" do
77
82
  @page.something = nil;
78
83
  @page.to_s.should == 'something=null;'
79
84
  end
80
-
85
+
81
86
  it "should provide access to javascript context variables" do
82
87
  @page.get(:my_var).property = 'boo';
83
88
  @page.to_s.should == 'my_var.property="boo";'
84
89
  end
85
-
90
+
86
91
  it "should let you set the variables" do
87
92
  @page.set(:my_var, nil)
88
93
  @page.to_s.should == 'var my_var=null;'
89
94
  end
90
-
95
+
91
96
  it "should process << pushes correctly" do
92
97
  @page << 'some_code();' << 'another_code();'
93
98
  @page.to_s.should == 'some_code();another_code();'
94
99
  end
95
-
100
+
96
101
  it "should convert several lines of code properly" do
97
102
  @page['el1'].update('text1').show();
98
103
  @page['el2'].update('text2').highlight();
99
-
104
+
100
105
  @page.to_s.should == '$("el1").update("text1").show();$("el2").update("text2").highlight();'
101
106
  end
102
-
107
+
103
108
  describe "in safe-mode" do
104
109
  before :each do
105
110
  RightRails::Config.safe_mode = true
106
111
  end
107
-
112
+
108
113
  it "should prefix $ with RightJS." do
109
114
  @page['element-id']
110
115
  @page.to_s.should == 'RightJS.$("element-id");'
111
116
  end
112
-
117
+
113
118
  it "should prefix $$ with RightJS." do
114
119
  @page.find('div#css.rule')
115
120
  @page.to_s.should == 'RightJS.$$("div#css.rule");'
116
121
  end
117
122
  end
118
123
  end
119
-
124
+
120
125
  describe "second level calls" do
121
126
  it "should catch up an element method simple calls" do
122
127
  @page['element-id'].myMethod
@@ -137,35 +142,35 @@ describe RightRails::JavaScriptGenerator do
137
142
  @page['element-id'].test(1).show.highlight()
138
143
  @page.to_s.should == '$("element-id").test(1).show().highlight();'
139
144
  end
140
-
145
+
141
146
  it "should catch up the assignments correctly" do
142
147
  @page['element-id'].innerHTML = nil;
143
148
  @page.to_s.should == '$("element-id").innerHTML=null;'
144
149
  end
145
-
150
+
146
151
  it "should catch the property assignment calls too" do
147
152
  @page['element-id'][:title] = 'something';
148
153
  @page.to_s.should == '$("element-id").title="something";'
149
154
  end
150
-
155
+
151
156
  it "should process other methods calls as arguments" do
152
157
  @page['element-id'].update(@page.my_method(@page.another_method(1,2),3,nil))
153
158
  @page.to_s.should == '$("element-id").update(my_method(another_method(1,2),3,null));'
154
159
  end
155
-
160
+
156
161
  it "should process operation calls" do
157
162
  @page.property = @page.first + @page.another(1,nil) * @page.more / 2 -
158
163
  @page.get(:thing) / @page.another(2) + nil - 'boo' + @page.last(@page.first)
159
-
164
+
160
165
  @page.to_s.should == 'property=first()+another(1,null)*more()/2-thing/another(2)+null-"boo"+last(first());'
161
166
  end
162
-
167
+
163
168
  it "should process the append operation" do
164
169
  @page['element'][:innerHTML] << 'boo'
165
170
  @page.to_s.should == '$("element").innerHTML+="boo";'
166
171
  end
167
172
  end
168
-
173
+
169
174
  describe "data types conversion" do
170
175
  it "should correctly process numeric arguments" do
171
176
  @page['element-id'].test(1, 2.3)
@@ -206,101 +211,101 @@ describe RightRails::JavaScriptGenerator do
206
211
  })
207
212
  @page.to_s.should == '$("element-id").test({"four":{"five":true,"six":null},one:1,two:2.3});'
208
213
  end
209
-
214
+
210
215
  it "should handle JSON exportable units too" do
211
216
  @value = ActiveRecord::Base.new({:id => '22'});
212
217
  def @value.to_json
213
218
  {:id => id}
214
219
  end
215
-
220
+
216
221
  @page["element-id"].test(@value)
217
222
  @page.to_s.should == '$("element-id").test({id:"22"});'
218
223
  end
219
-
224
+
220
225
  it "should convert lambdas to functions" do
221
226
  @page.find("boo").each(lambda{ |item, i, array|
222
227
  item.boo(i.foo(2)) + array.hoo
223
228
  })
224
229
  @page.to_s.should == '$$("boo").each(function(a,b,c){a.boo(b.foo(2))+c.hoo();});'
225
230
  end
226
-
231
+
227
232
  it "should process blocks nicely" do
228
233
  @page.find("boo").each do |item, i|
229
234
  item.boo(i.foo('hoo'))
230
235
  end
231
-
236
+
232
237
  @page.to_s.should == '$$("boo").each(function(a,b){a.boo(b.foo("hoo"));});'
233
238
  end
234
-
239
+
235
240
  it "should process blocks with scope variables and the page builder calls" do
236
241
  some_text = 'boo'
237
-
242
+
238
243
  @page.find("foo").each do |item, index|
239
244
  @page['element'][:innerHTML] << item[:innerHTML] + index + some_text
240
245
  end
241
-
246
+
242
247
  # checking that the context is getting back
243
248
  @page.alert(@page['element'][:innerHTML])
244
-
249
+
245
250
  @page.to_s.should == '$$("foo").each(function(a,b){$("element").innerHTML+=a.innerHTML+b+"boo";});alert($("element").innerHTML);'
246
251
  end
247
-
252
+
248
253
  it "should throw an error for unknown data-types" do
249
254
  class Booooooooooo
250
255
  def respond_to?(name)
251
256
  name.to_sym == :to_json ? false : super(name)
252
257
  end
253
258
  end
254
-
259
+
255
260
  lambda {
256
261
  @page['element'].insert(Booooooooooo.new)
257
262
  }.should raise_error
258
263
  end
259
264
  end
260
-
265
+
261
266
  describe "RR object method calls generator" do
262
267
  before :each do
263
268
  @record = ActiveRecord::Base.new({:id => '22'})
264
269
  end
265
-
270
+
266
271
  it "should generate script for the 'insert' request" do
267
272
  @template.should_receive(:render).with(@record).and_return('<record html code/>')
268
-
273
+
269
274
  @page.insert(@record)
270
275
  @page.to_s.should == 'RR.insert("records","<record html code/>");'
271
276
  end
272
-
277
+
273
278
  it "should generate script for the 'replace' request" do
274
279
  @template.should_receive(:render).with(@record).and_return('<record html code/>')
275
-
280
+
276
281
  @page.replace(@record)
277
282
  @page.to_s.should == 'RR.replace("record_22","<record html code/>");'
278
283
  end
279
-
284
+
280
285
  it "should generate script for the 'remove' request" do
281
286
  @page.remove(@record)
282
287
  @page.to_s.should == 'RR.remove("record_22");'
283
288
  end
284
-
289
+
285
290
  it "should generate script for the 'show_form_for' request" do
286
291
  @template.should_receive(:render).with('form').and_return('<the form html code/>')
287
-
292
+
288
293
  @page.show_form_for(@record)
289
294
  @page.to_s.should == 'RR.show_form_for("record_22","<the form html code/>");'
290
295
  end
291
-
296
+
292
297
  describe "replace_form_for generator" do
293
298
  before :each do
294
299
  @template.should_receive(:render).with('form').and_return('<the form html code/>')
295
300
  end
296
-
301
+
297
302
  it "should generate a script for a new record" do
298
303
  @record.should_receive(:new_record?).and_return(true)
299
304
 
300
305
  @page.replace_form_for(@record)
301
306
  @page.to_s.should == 'RR.replace_form("new_record","<the form html code/>");'
302
307
  end
303
-
308
+
304
309
  it "should generate a script for an existing record" do
305
310
  @record.should_receive(:new_record?).and_return(false)
306
311
 
@@ -308,13 +313,13 @@ describe RightRails::JavaScriptGenerator do
308
313
  @page.to_s.should == 'RR.replace_form("edit_record_22","<the form html code/>");'
309
314
  end
310
315
  end
311
-
316
+
312
317
  describe "updates with care" do
313
318
  before :each do
314
319
  @template.should_receive(:flashes).and_return('<flashes/>')
315
320
  @template.should_receive(:flash).and_return(mock(:flash, {:clear => true}))
316
321
  end
317
-
322
+
318
323
  it "should generate response for #update_flash" do
319
324
  @page.update_flash
320
325
  @page.to_s.should == 'RR.update_flash("<flashes/>");'
@@ -330,7 +335,7 @@ describe RightRails::JavaScriptGenerator do
330
335
  'RR.replace_form("new_record","<the form html code/>");' +
331
336
  'RR.update_flash("<flashes/>");'
332
337
  end
333
-
338
+
334
339
  it "should generate response for the #replace_and_care method" do
335
340
  @template.should_receive(:render).with(@record).and_return('<record html code/>')
336
341
 
@@ -340,8 +345,8 @@ describe RightRails::JavaScriptGenerator do
340
345
  'RR.update_flash("<flashes/>");'
341
346
  end
342
347
  end
343
-
348
+
344
349
  end
345
-
346
-
350
+
351
+
347
352
  end