autoforme 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fdba8a6d624942582b3ca471ea9843bbb52cfc12
4
- data.tar.gz: 8d01c8751490a15de34459e41b0ebf5440ee9f59
3
+ metadata.gz: 56859c9eb572815d56f455bc3427653ed4365c0c
4
+ data.tar.gz: 65f69c05fbb2a9b4a9836c0cd690faf4aa2ec2cf
5
5
  SHA512:
6
- metadata.gz: 00fa2b89b05bde608fb09dc4dc54daadce1a8c622184e7a8ee18477eccc24a44be561ab3077b93327c060bf9f4c996b6a3cdacaa8025bc33d11e5026a4cf105c
7
- data.tar.gz: f2d0e910488aefef9e4ffff4ec23bf9a050622b17c0f317a5d2b1ee71579dedca429b9181a25f77262c9e39fca0327d44151e038ceb28b9bb9cf9f7f3ca5a17a
6
+ metadata.gz: a539a998ae3809da0de0a4343b6401bd0cab87ba22e75874845e019ec7fcea48a79206aa1d80ba16a999a3d8b67cb61f1f733c175b86504694bd8547ab035a6a
7
+ data.tar.gz: 31781cf212c8cb7bdeff9359ddd643cb2647005d552b04c038cc91470345aa56130bd0b60c43b64091f31c6ea2fc8edd4b882a50754deeabff8b39b542106155
data/CHANGELOG CHANGED
@@ -1,3 +1,11 @@
1
+ === 1.0.2 (2014-12-17)
2
+
3
+ * Fix double escaping of & in inline mtm edit forms, fixing usage with rack 1.6.0 beta (jeremyevans)
4
+
5
+ * Work with roda when using static_path_info plugin (jeremyevans)
6
+
7
+ * Make sure the display name for an object always returns a string (jeremyevans)
8
+
1
9
  === 1.0.1 (2014-08-19)
2
10
 
3
11
  * Display BigDecimal values in float format on browse/search pages (jeremyevans)
@@ -596,7 +596,7 @@ module AutoForme
596
596
 
597
597
  t = "<div class='inline_mtm_add_associations'>"
598
598
  assocs.each do |assoc|
599
- form_attr = form_attributes(:action=>url_for("mtm_update/#{model.primary_key_value(obj)}?association=#{assoc}&amp;redir=edit"), :class => 'mtm_add_associations', 'data-remove' => "##{assoc}_remove_list")
599
+ form_attr = form_attributes(:action=>url_for("mtm_update/#{model.primary_key_value(obj)}?association=#{assoc}&redir=edit"), :class => 'mtm_add_associations', 'data-remove' => "##{assoc}_remove_list")
600
600
  t << Forme.form(obj, form_attr, form_opts) do |f|
601
601
  opts = model.column_options_for(:mtm_edit, request, assoc)
602
602
  add_opts = opts[:add] ? opts.merge(opts.delete(:add)) : opts.dup
@@ -628,7 +628,7 @@ module AutoForme
628
628
  def mtm_edit_remove(assoc, mc, obj, assoc_obj)
629
629
  t = "<li>"
630
630
  t << association_link(mc, assoc_obj)
631
- form_attr = form_attributes(:action=>url_for("mtm_update/#{model.primary_key_value(obj)}?association=#{assoc}&amp;remove%5b%5d=#{model.primary_key_value(assoc_obj)}&amp;redir=edit"), :method=>'post', :class => 'mtm_remove_associations', 'data-add'=>"#add_#{assoc}")
631
+ form_attr = form_attributes(:action=>url_for("mtm_update/#{model.primary_key_value(obj)}?association=#{assoc}&remove%5b%5d=#{model.primary_key_value(assoc_obj)}&redir=edit"), :method=>'post', :class => 'mtm_remove_associations', 'data-add'=>"#add_#{assoc}")
632
632
  t << Forme.form(form_attr, form_opts) do |f|
633
633
  f.button(:value=>'Remove', :class=>'btn btn-mini btn-danger')
634
634
  end.to_s
@@ -13,7 +13,12 @@ module AutoForme
13
13
  @model = captures[-2]
14
14
  @action_type = captures[-1]
15
15
  @path = path
16
- @id = @params['id'] || ($1 if @env['PATH_INFO'] =~ %r{\A\/(\w+)\z})
16
+ remaining_path = if @request.respond_to?(:remaining_path)
17
+ @request.remaining_path
18
+ else
19
+ @env['PATH_INFO']
20
+ end
21
+ @id = @params['id'] || ($1 if remaining_path =~ %r{\A\/(\w+)\z})
17
22
  end
18
23
 
19
24
  # Redirect to the given path
@@ -47,11 +52,12 @@ module AutoForme
47
52
 
48
53
  @route_proc = lambda do
49
54
  r = request
50
- path = r.env['SCRIPT_NAME']
51
- current_matchers = matchers.dup
52
- current_matchers << lambda do
53
- @autoforme_action = framework.action_for(Request.new(self, path))
55
+ path = if r.respond_to?(:matched_path)
56
+ r.matched_path
57
+ else
58
+ r.env['SCRIPT_NAME']
54
59
  end
60
+ current_matchers = matchers + [lambda{@autoforme_action = framework.action_for(Request.new(self, path))}]
55
61
 
56
62
  r.on *current_matchers do
57
63
  @autoforme_text = @autoforme_action.handle
@@ -311,7 +311,7 @@ module AutoForme
311
311
 
312
312
  # A human readable string representing the object.
313
313
  def object_display_name(type, request, obj)
314
- apply_name_method(display_name_for, obj, type, request)
314
+ apply_name_method(display_name_for, obj, type, request).to_s
315
315
  end
316
316
 
317
317
  # A human reable string for the associated object.
@@ -327,7 +327,7 @@ module AutoForme
327
327
  obj.name
328
328
  else
329
329
  primary_key_value(obj)
330
- end
330
+ end.to_s
331
331
  end
332
332
 
333
333
  private
@@ -1,6 +1,6 @@
1
1
  module AutoForme
2
2
  # Version constant, use <tt>AutoForme.version</tt> instead.
3
- VERSION = '1.0.1'.freeze
3
+ VERSION = '1.0.2'.freeze
4
4
 
5
5
  # Returns the version as a frozen string (e.g. '0.1.0')
6
6
  def self.version
@@ -45,10 +45,10 @@ describe AutoForme do
45
45
  fill_in 'Name', :with=>'1b'
46
46
  select 'Artist2'
47
47
  click_button 'Search'
48
- all('td').map{|s| s.text}.should == ["Album1b", "Artist2", "Show", "Edit", "Delete"]
48
+ page.all('td').map{|s| s.text}.should == ["Album1b", "Artist2", "Show", "Edit", "Delete"]
49
49
 
50
50
  click_link 'Album'
51
- all('td').map{|s| s.text}.should == ["Album1b", "Artist2", "Show", "Edit", "Delete"]
51
+ page.all('td').map{|s| s.text}.should == ["Album1b", "Artist2", "Show", "Edit", "Delete"]
52
52
  end
53
53
 
54
54
  it "should use text boxes for associated objects on new/edit/search forms if associated model uses autocompleting" do
@@ -82,7 +82,7 @@ describe AutoForme do
82
82
  fill_in 'Name', :with=>'1b'
83
83
  fill_in 'Artist', :with=>b.id.to_s
84
84
  click_button 'Search'
85
- all('td').map{|s| s.text}.should == ["Album1b", "TestArtist2", "Show", "Edit", "Delete"]
85
+ page.all('td').map{|s| s.text}.should == ["Album1b", "TestArtist2", "Show", "Edit", "Delete"]
86
86
  end
87
87
 
88
88
  it "should be able to used specified name formatting in other model" do
@@ -123,10 +123,10 @@ describe AutoForme do
123
123
  fill_in 'Name', :with=>'1b'
124
124
  select 'A2A2'
125
125
  click_button 'Search'
126
- all('td').map{|s| s.text}.should == ["Album1b", "A2A2", "Show", "Edit", "Delete"]
126
+ page.all('td').map{|s| s.text}.should == ["Album1b", "A2A2", "Show", "Edit", "Delete"]
127
127
 
128
128
  click_link 'Album'
129
- all('td').map{|s| s.text}.should == ["Album1b", "A2A2", "Show", "Edit", "Delete"]
129
+ page.all('td').map{|s| s.text}.should == ["Album1b", "A2A2", "Show", "Edit", "Delete"]
130
130
  end
131
131
 
132
132
  it "should be able to used specified name formatting for current association" do
@@ -166,10 +166,10 @@ describe AutoForme do
166
166
  fill_in 'Name', :with=>'1b'
167
167
  select 'A2A2'
168
168
  click_button 'Search'
169
- all('td').map{|s| s.text}.should == ["Album1b", "A2A2", "Show", "Edit", "Delete"]
169
+ page.all('td').map{|s| s.text}.should == ["Album1b", "A2A2", "Show", "Edit", "Delete"]
170
170
 
171
171
  click_link 'Album'
172
- all('td').map{|s| s.text}.should == ["Album1b", "A2A2", "Show", "Edit", "Delete"]
172
+ page.all('td').map{|s| s.text}.should == ["Album1b", "A2A2", "Show", "Edit", "Delete"]
173
173
  end
174
174
 
175
175
  it "should be able to eager load associations when loading model" do
@@ -210,10 +210,10 @@ describe AutoForme do
210
210
  fill_in 'Name', :with=>'1b'
211
211
  select 'A2'
212
212
  click_button 'Search'
213
- all('td').map{|s| s.text}.should == ["Album1b", "A2", "Show", "Edit", "Delete"]
213
+ page.all('td').map{|s| s.text}.should == ["Album1b", "A2", "Show", "Edit", "Delete"]
214
214
 
215
215
  click_link 'Album'
216
- all('td').map{|s| s.text}.should == ["Album1b", "A2", "Show", "Edit", "Delete"]
216
+ page.all('td').map{|s| s.text}.should == ["Album1b", "A2", "Show", "Edit", "Delete"]
217
217
 
218
218
  click_link 'Delete'
219
219
  select 'A2-Album1b'
@@ -271,14 +271,14 @@ describe AutoForme do
271
271
  click_button 'Create'
272
272
 
273
273
  click_link 'Show'
274
- all('select option').map{|s| s.text}.should == ['', 'A-Y', 'B-X', 'B-Z']
274
+ page.all('select option').map{|s| s.text}.should == ['', 'A-Y', 'B-X', 'B-Z']
275
275
  select 'B-X'
276
276
  click_button 'Show'
277
277
  page.html.should =~ /Name.+X/m
278
278
  page.html.should =~ /Artist.+B/m
279
279
 
280
280
  click_link 'Edit'
281
- all('select option').map{|s| s.text}.should == ['', 'X (B)', 'Y (A)', 'Z (B)']
281
+ page.all('select option').map{|s| s.text}.should == ['', 'X (B)', 'Y (A)', 'Z (B)']
282
282
  select 'Z (B)'
283
283
  click_button 'Edit'
284
284
  fill_in 'Name', :with=>'ZZ'
@@ -288,13 +288,13 @@ describe AutoForme do
288
288
  click_link 'Search'
289
289
  select 'A'
290
290
  click_button 'Search'
291
- all('tr td:first-child').map{|s| s.text}.should == %w'Y ZZ'
291
+ page.all('tr td:first-child').map{|s| s.text}.should == %w'Y ZZ'
292
292
 
293
293
  click_link 'Album'
294
- all('tr td:first-child').map{|s| s.text}.should == %w'Y ZZ X'
294
+ page.all('tr td:first-child').map{|s| s.text}.should == %w'Y ZZ X'
295
295
 
296
296
  click_link 'Delete'
297
- all('select option').map{|s| s.text}.should == ['', 'A-Y', 'A-ZZ', 'B-X']
297
+ page.all('select option').map{|s| s.text}.should == ['', 'A-Y', 'A-ZZ', 'B-X']
298
298
  select 'B-X'
299
299
  click_button 'Delete'
300
300
  end
@@ -325,15 +325,15 @@ describe AutoForme do
325
325
 
326
326
  visit("/Album/new")
327
327
  fill_in 'Name', :with=>'E'
328
- all('select option').map{|s| s.text}.should == ['', 'X 0', 'Y 0', 'Z 0']
328
+ page.all('select option').map{|s| s.text}.should == ['', 'X 0', 'Y 0', 'Z 0']
329
329
  select 'X 0'
330
330
  click_button 'Create'
331
331
  fill_in 'Name', :with=>'D'
332
- all('select option').map{|s| s.text}.should == ['', 'X 1', 'Y 0', 'Z 0']
332
+ page.all('select option').map{|s| s.text}.should == ['', 'X 1', 'Y 0', 'Z 0']
333
333
  select 'Y 0'
334
334
  click_button 'Create'
335
335
  fill_in 'Name', :with=>'C'
336
- all('select option').map{|s| s.text}.should == ['', 'X 1', 'Y 1', 'Z 0']
336
+ page.all('select option').map{|s| s.text}.should == ['', 'X 1', 'Y 1', 'Z 0']
337
337
  select 'Y 1'
338
338
  click_button 'Create'
339
339
 
@@ -346,21 +346,21 @@ describe AutoForme do
346
346
  click_link 'Edit'
347
347
  select 'C'
348
348
  click_button 'Edit'
349
- all('select option').map{|s| s.text}.should == ['', 'X 1', 'Y 2', 'Z 0']
349
+ page.all('select option').map{|s| s.text}.should == ['', 'X 1', 'Y 2', 'Z 0']
350
350
  select 'X 1'
351
351
  click_button 'Update'
352
352
 
353
353
  click_link 'Search'
354
- all('select option').map{|s| s.text}.should == ['', 'X 2', 'Y 1', 'Z 0']
354
+ page.all('select option').map{|s| s.text}.should == ['', 'X 2', 'Y 1', 'Z 0']
355
355
  select 'X 2'
356
356
  click_button 'Search'
357
- all('tr td:first-child').map{|s| s.text}.should == %w'C E'
357
+ page.all('tr td:first-child').map{|s| s.text}.should == %w'C E'
358
358
 
359
359
  click_link 'Album'
360
- all('tr td:first-child').map{|s| s.text}.should == %w'C D E'
360
+ page.all('tr td:first-child').map{|s| s.text}.should == %w'C D E'
361
361
 
362
362
  click_link 'Delete'
363
- all('select option').map{|s| s.text}.should == ['', 'C', 'D', 'E']
363
+ page.all('select option').map{|s| s.text}.should == ['', 'C', 'D', 'E']
364
364
  select 'C'
365
365
  click_button 'Delete'
366
366
  click_button 'Delete'
@@ -375,7 +375,7 @@ describe AutoForme do
375
375
  select 'X 1'
376
376
  Artist.where(:name=>'X').update(:name=>'B')
377
377
  click_button 'Search'
378
- all('tr td:first-child').map{|s| s.text}.should == []
378
+ page.all('tr td:first-child').map{|s| s.text}.should == []
379
379
  end
380
380
 
381
381
  it "should have working one to many and many to one association links on show and edit pages" do
@@ -421,6 +421,36 @@ describe AutoForme do
421
421
  page.current_path.should == '/Album/browse'
422
422
  end
423
423
 
424
+ it "should display but not link if the action is not supported " do
425
+ app_setup do
426
+ model Artist do
427
+ association_links :all
428
+ end
429
+ model Album do
430
+ association_links :all
431
+ supported_actions [:new]
432
+ display_name{|o| o.name.to_sym}
433
+ end
434
+ end
435
+
436
+ visit("/Artist/new")
437
+ fill_in 'Name', :with=>'Artist1'
438
+ click_button 'Create'
439
+
440
+ click_link 'Edit'
441
+ select 'Artist1'
442
+ click_button 'Edit'
443
+ click_link 'create'
444
+ fill_in 'Name', :with=>'Album1'
445
+ click_button 'Create'
446
+
447
+ visit("/Artist/edit")
448
+ select 'Artist1'
449
+ click_button 'Edit'
450
+ page.html.should =~ /Album1/
451
+ page.html.should_not =~ />edit</
452
+ end
453
+
424
454
  it "should support lazy loading association links on show and edit pages" do
425
455
  app_setup do
426
456
  model Artist do
@@ -522,10 +552,10 @@ describe AutoForme do
522
552
  fill_in 'Name', :with=>'1b'
523
553
  select 'Artist2'
524
554
  click_button 'Search'
525
- all('td').map{|s| s.text}.should == ["Album1b", "Artist2", "Show", "Edit", "Delete"]
555
+ page.all('td').map{|s| s.text}.should == ["Album1b", "Artist2", "Show", "Edit", "Delete"]
526
556
 
527
557
  click_link 'Album'
528
- all('td').map{|s| s.text}.should == ["Album1b", "Artist2", "Show", "Edit", "Delete"]
558
+ page.all('td').map{|s| s.text}.should == ["Album1b", "Artist2", "Show", "Edit", "Delete"]
529
559
  end
530
560
 
531
561
  it "should have basic many to one associations working" do
@@ -566,10 +596,10 @@ describe AutoForme do
566
596
  fill_in 'Name', :with=>'1b'
567
597
  select 'Artist2'
568
598
  click_button 'Search'
569
- all('td').map{|s| s.text}.should == ["Album1b", "Artist2", "Show", "Edit", "Delete"]
599
+ page.all('td').map{|s| s.text}.should == ["Album1b", "Artist2", "Show", "Edit", "Delete"]
570
600
 
571
601
  click_link 'Album'
572
- all('td').map{|s| s.text}.should == ["Album1b", "Artist2", "Show", "Edit", "Delete"]
602
+ page.all('td').map{|s| s.text}.should == ["Album1b", "Artist2", "Show", "Edit", "Delete"]
573
603
  end
574
604
  end
575
605
 
@@ -594,9 +624,9 @@ describe AutoForme do
594
624
 
595
625
  %w'A1 E1 L1 N1'.each{|n| Artist.create(:name=>n)}
596
626
  visit("/Album/new")
597
- all('select option').map{|s| s.text}.should == ["", "A1", "E1", "L1"]
627
+ page.all('select option').map{|s| s.text}.should == ["", "A1", "E1", "L1"]
598
628
 
599
629
  visit("/Album/edit/#{Album.create(:name=>'Album1').id}")
600
- all('select option').map{|s| s.text}.should == ["", "L1", "E1"]
630
+ page.all('select option').map{|s| s.text}.should == ["", "L1", "E1"]
601
631
  end
602
632
  end
@@ -38,26 +38,26 @@ describe AutoForme do
38
38
  page.find('title').text.should == 'Artist - Search'
39
39
  fill_in 'Name', :with=>'Upd'
40
40
  click_button 'Search'
41
- all('th').map{|s| s.text}.should == ['Name', 'Show', 'Edit', 'Delete']
42
- all('td').map{|s| s.text}.should == ["TestArtistUpdate", "Show", "Edit", "Delete"]
41
+ page.all('th').map{|s| s.text}.should == ['Name', 'Show', 'Edit', 'Delete']
42
+ page.all('td').map{|s| s.text}.should == ["TestArtistUpdate", "Show", "Edit", "Delete"]
43
43
 
44
44
  click_link 'Search'
45
45
  fill_in 'Name', :with=>'Foo'
46
46
  click_button 'Search'
47
- all('td').map{|s| s.text}.should == []
47
+ page.all('td').map{|s| s.text}.should == []
48
48
 
49
49
  click_link 'Artist'
50
50
  page.find('title').text.should == 'Artist - Browse'
51
- all('td').map{|s| s.text}.should == ["TestArtistUpdate", "Show", "Edit", "Delete"]
51
+ page.all('td').map{|s| s.text}.should == ["TestArtistUpdate", "Show", "Edit", "Delete"]
52
52
 
53
- all('td').last.find('a').click
53
+ page.all('td').last.find('a').click
54
54
  click_button 'Delete'
55
55
  page.find('title').text.should == 'Artist - Delete'
56
56
  page.html.should =~ /Deleted Artist/
57
57
  page.current_path.should == '/Artist/delete'
58
58
 
59
59
  click_link 'Artist'
60
- all('td').map{|s| s.text}.should == []
60
+ page.all('td').map{|s| s.text}.should == []
61
61
  end
62
62
 
63
63
  it "should have basic functionality working in a subdirectory" do
@@ -85,24 +85,24 @@ describe AutoForme do
85
85
  click_link 'Search'
86
86
  fill_in 'Name', :with=>'Upd'
87
87
  click_button 'Search'
88
- all('th').map{|s| s.text}.should == ['Name', 'Show', 'Edit', 'Delete']
89
- all('td').map{|s| s.text}.should == ["TestArtistUpdate", "Show", "Edit", "Delete"]
88
+ page.all('th').map{|s| s.text}.should == ['Name', 'Show', 'Edit', 'Delete']
89
+ page.all('td').map{|s| s.text}.should == ["TestArtistUpdate", "Show", "Edit", "Delete"]
90
90
 
91
91
  click_link 'Search'
92
92
  fill_in 'Name', :with=>'Foo'
93
93
  click_button 'Search'
94
- all('td').map{|s| s.text}.should == []
94
+ page.all('td').map{|s| s.text}.should == []
95
95
 
96
96
  click_link 'Artist'
97
- all('td').map{|s| s.text}.should == ["TestArtistUpdate", "Show", "Edit", "Delete"]
97
+ page.all('td').map{|s| s.text}.should == ["TestArtistUpdate", "Show", "Edit", "Delete"]
98
98
 
99
- all('td').last.find('a').click
99
+ page.all('td').last.find('a').click
100
100
  click_button 'Delete'
101
101
  page.html.should =~ /Deleted Artist/
102
102
  page.current_path.should == '/prefix/Artist/delete'
103
103
 
104
104
  click_link 'Artist'
105
- all('td').map{|s| s.text}.should == []
105
+ page.all('td').map{|s| s.text}.should == []
106
106
  end
107
107
 
108
108
  it "should have delete button on edit page" do
@@ -195,10 +195,10 @@ describe AutoForme do
195
195
  click_link 'Search'
196
196
  fill_in 'Search_form Artist Name', :with=>'Upd'
197
197
  click_button 'Search'
198
- all('th').map{|s| s.text}.should == ["Search Artist Name", "Show", "Edit", "Delete"]
198
+ page.all('th').map{|s| s.text}.should == ["Search Artist Name", "Show", "Edit", "Delete"]
199
199
 
200
200
  click_link 'Artist'
201
- all('th').map{|s| s.text}.should == ["Browse Artist Name", "Show", "Edit", "Delete"]
201
+ page.all('th').map{|s| s.text}.should == ["Browse Artist Name", "Show", "Edit", "Delete"]
202
202
  end
203
203
 
204
204
  it "should support specifying display names per type" do
@@ -306,26 +306,26 @@ describe AutoForme do
306
306
  5.times{|i| Artist.create(:name=>i.to_s)}
307
307
  visit("/Artist/browse")
308
308
  first('li.disabled a').text.should == 'Previous'
309
- all('tr td:first-child').map{|s| s.text}.should == %w'0 1'
309
+ page.all('tr td:first-child').map{|s| s.text}.should == %w'0 1'
310
310
  click_link 'Next'
311
- all('tr td:first-child').map{|s| s.text}.should == %w'2 3'
311
+ page.all('tr td:first-child').map{|s| s.text}.should == %w'2 3'
312
312
  click_link 'Next'
313
- all('tr td:first-child').map{|s| s.text}.should == %w'4'
313
+ page.all('tr td:first-child').map{|s| s.text}.should == %w'4'
314
314
  first('li.disabled a').text.should == 'Next'
315
315
  click_link 'Previous'
316
- all('tr td:first-child').map{|s| s.text}.should == %w'2 3'
316
+ page.all('tr td:first-child').map{|s| s.text}.should == %w'2 3'
317
317
  click_link 'Previous'
318
- all('tr td:first-child').map{|s| s.text}.should == %w'0 1'
318
+ page.all('tr td:first-child').map{|s| s.text}.should == %w'0 1'
319
319
  first('li.disabled a').text.should == 'Previous'
320
320
 
321
321
  click_link 'Search'
322
322
  click_button 'Search'
323
- all('tr td:first-child').map{|s| s.text}.should == %w'0 1 2'
323
+ page.all('tr td:first-child').map{|s| s.text}.should == %w'0 1 2'
324
324
  click_link 'Next'
325
- all('tr td:first-child').map{|s| s.text}.should == %w'3 4'
325
+ page.all('tr td:first-child').map{|s| s.text}.should == %w'3 4'
326
326
  first('li.disabled a').text.should == 'Next'
327
327
  click_link 'Previous'
328
- all('tr td:first-child').map{|s| s.text}.should == %w'0 1 2'
328
+ page.all('tr td:first-child').map{|s| s.text}.should == %w'0 1 2'
329
329
  first('li.disabled a').text.should == 'Previous'
330
330
  end
331
331
 
@@ -351,10 +351,10 @@ describe AutoForme do
351
351
  click_link 'Search'
352
352
  fill_in 'Name', :with=>'Upd'
353
353
  click_button 'Search'
354
- all('td').map{|s| s.text}.should == ["TestArtistUpdate", "Edit"]
354
+ page.all('td').map{|s| s.text}.should == ["TestArtistUpdate", "Edit"]
355
355
 
356
356
  click_link 'Artist'
357
- all('td').map{|s| s.text}.should == ["TestArtistUpdate", "Edit"]
357
+ page.all('td').map{|s| s.text}.should == ["TestArtistUpdate", "Edit"]
358
358
  end
359
359
 
360
360
  it "should have basic functionality working" do
@@ -376,9 +376,9 @@ describe AutoForme do
376
376
  page.html.should =~ /Updated FooArtist/
377
377
 
378
378
  click_link 'FooArtist'
379
- all('td').map{|s| s.text}.should == ["TestArtistUpdate", "Show", "Edit", "Delete"]
379
+ page.all('td').map{|s| s.text}.should == ["TestArtistUpdate", "Show", "Edit", "Delete"]
380
380
 
381
- all('td').last.find('a').click
381
+ page.all('td').last.find('a').click
382
382
  click_button 'Delete'
383
383
  page.html.should =~ /Deleted FooArtist/
384
384
  end
@@ -466,10 +466,10 @@ describe AutoForme do
466
466
  fill_in 'N4', :with=>'V4'
467
467
  fill_in 'N5', :with=>'Q5'
468
468
  click_button 'Search'
469
- all('td').map{|s| s.text}.should == ["Q1", "Q2", "Q3", "V4", "Q5", "Show", "Edit", "Delete"]
469
+ page.all('td').map{|s| s.text}.should == ["Q1", "Q2", "Q3", "V4", "Q5", "Show", "Edit", "Delete"]
470
470
 
471
471
  click_link 'Artist'
472
- all('td').map{|s| s.text}.should == ["Q0", "Q1", "Q3", "V4", "Q5", "Show", "Edit", "Delete"]
472
+ page.all('td').map{|s| s.text}.should == ["Q0", "Q1", "Q3", "V4", "Q5", "Show", "Edit", "Delete"]
473
473
  end
474
474
 
475
475
  it "should support specifying order per type" do
@@ -483,20 +483,20 @@ describe AutoForme do
483
483
  Artist.create(:n0=>'0', :n1=>'4', :n2=>'1', :n3=>'5', :n4=>'3')
484
484
 
485
485
  visit("/Artist/show")
486
- all('option').map{|s| s.text}.should == ['', '2', '1', '0']
486
+ page.all('option').map{|s| s.text}.should == ['', '2', '1', '0']
487
487
 
488
488
  click_link 'Edit'
489
- all('option').map{|s| s.text}.should == ['', '0', '1', '2']
489
+ page.all('option').map{|s| s.text}.should == ['', '0', '1', '2']
490
490
 
491
491
  click_link 'Delete'
492
- all('option').map{|s| s.text}.should == ['', '2', '0', '1']
492
+ page.all('option').map{|s| s.text}.should == ['', '2', '0', '1']
493
493
 
494
494
  click_link 'Search'
495
495
  click_button 'Search'
496
- all('tr td:first-child').map{|s| s.text}.should == ['0', '2', '1']
496
+ page.all('tr td:first-child').map{|s| s.text}.should == ['0', '2', '1']
497
497
 
498
498
  click_link 'Artist'
499
- all('tr td:first-child').map{|s| s.text}.should == ['1', '2', '0']
499
+ page.all('tr td:first-child').map{|s| s.text}.should == ['1', '2', '0']
500
500
  end
501
501
 
502
502
  it "should support specifying filter per type" do
@@ -522,16 +522,16 @@ describe AutoForme do
522
522
  Artist.create(:n0=>'0', :n1=>'4', :n2=>'1', :n3=>'5', :n4=>'3')
523
523
 
524
524
  visit("/Artist/show")
525
- all('option').map{|s| s.text}.should == ['', '0']
525
+ page.all('option').map{|s| s.text}.should == ['', '0']
526
526
 
527
527
  click_link 'Edit'
528
- all('option').map{|s| s.text}.should == ['', '2']
528
+ page.all('option').map{|s| s.text}.should == ['', '2']
529
529
  select '2'
530
530
  click_button 'Edit'
531
531
  click_button 'Update'
532
532
 
533
533
  click_link 'Delete'
534
- all('option').map{|s| s.text}.should == ['', '1']
534
+ page.all('option').map{|s| s.text}.should == ['', '1']
535
535
  select '1'
536
536
  click_button 'Delete'
537
537
  click_button 'Delete'
@@ -539,10 +539,10 @@ describe AutoForme do
539
539
 
540
540
  click_link 'Search'
541
541
  click_button 'Search'
542
- all('tr td:first-child').map{|s| s.text}.should == %w'1'
542
+ page.all('tr td:first-child').map{|s| s.text}.should == %w'1'
543
543
 
544
544
  click_link 'Artist'
545
- all('tr td:first-child').map{|s| s.text}.should == %w'1'
545
+ page.all('tr td:first-child').map{|s| s.text}.should == %w'1'
546
546
  end
547
547
 
548
548
  it "should support specifying filter per type using request params" do
@@ -569,19 +569,19 @@ describe AutoForme do
569
569
  Artist.create(:n0=>'0', :n1=>'4', :n2=>'1', :n3=>'5', :n4=>'3')
570
570
 
571
571
  visit("/Artist/show?f=3")
572
- all('option').map{|s| s.text}.should == ['', '0']
572
+ page.all('option').map{|s| s.text}.should == ['', '0']
573
573
 
574
574
  visit("/Artist/edit?f=1")
575
- all('option').map{|s| s.text}.should == ['', '2']
575
+ page.all('option').map{|s| s.text}.should == ['', '2']
576
576
 
577
577
  visit("/Artist/delete?f=2")
578
- all('option').map{|s| s.text}.should == ['', '1']
578
+ page.all('option').map{|s| s.text}.should == ['', '1']
579
579
 
580
580
  visit("/Artist/search/1?f=4")
581
- all('tr td:first-child').map{|s| s.text}.should == %w'1'
581
+ page.all('tr td:first-child').map{|s| s.text}.should == %w'1'
582
582
 
583
583
  visit("/Artist/browse?f=6")
584
- all('tr td:first-child').map{|s| s.text}.should == %w'1'
584
+ page.all('tr td:first-child').map{|s| s.text}.should == %w'1'
585
585
  end
586
586
 
587
587
  it "should support specifying filter per type using request session" do
@@ -596,16 +596,16 @@ describe AutoForme do
596
596
  visit '/session/set?n1=2'
597
597
 
598
598
  visit("/Artist/show")
599
- all('option').map{|s| s.text}.should == ['', '2', '1']
599
+ page.all('option').map{|s| s.text}.should == ['', '2', '1']
600
600
 
601
601
  click_link 'Edit'
602
- all('option').map{|s| s.text}.should == ['', '2', '1']
602
+ page.all('option').map{|s| s.text}.should == ['', '2', '1']
603
603
  select '2'
604
604
  click_button 'Edit'
605
605
  click_button 'Update'
606
606
 
607
607
  click_link 'Delete'
608
- all('option').map{|s| s.text}.should == ['', '2', '1']
608
+ page.all('option').map{|s| s.text}.should == ['', '2', '1']
609
609
  select '1'
610
610
  click_button 'Delete'
611
611
  click_button 'Delete'
@@ -613,10 +613,10 @@ describe AutoForme do
613
613
 
614
614
  click_link 'Search'
615
615
  click_button 'Search'
616
- all('tr td:first-child').map{|s| s.text}.should == %w'2 1'
616
+ page.all('tr td:first-child').map{|s| s.text}.should == %w'2 1'
617
617
 
618
618
  click_link 'Artist'
619
- all('tr td:first-child').map{|s| s.text}.should == %w'2 1'
619
+ page.all('tr td:first-child').map{|s| s.text}.should == %w'2 1'
620
620
  end
621
621
 
622
622
  it "should support session_value for restricting access by matching session variable to column value" do
@@ -638,23 +638,23 @@ describe AutoForme do
638
638
  click_button 'Create'
639
639
 
640
640
  click_link 'Show'
641
- all('option').map{|s| s.text}.should == ['', '2', '1']
641
+ page.all('option').map{|s| s.text}.should == ['', '2', '1']
642
642
 
643
643
  click_link 'Edit'
644
- all('option').map{|s| s.text}.should == ['', '2', '1']
644
+ page.all('option').map{|s| s.text}.should == ['', '2', '1']
645
645
  select '2'
646
646
  click_button 'Edit'
647
647
  click_button 'Update'
648
648
 
649
649
  click_link 'Search'
650
650
  click_button 'Search'
651
- all('tr td:first-child').map{|s| s.text}.should == %w'2 1'
651
+ page.all('tr td:first-child').map{|s| s.text}.should == %w'2 1'
652
652
 
653
653
  click_link 'Artist'
654
- all('tr td:first-child').map{|s| s.text}.should == %w'2 1'
654
+ page.all('tr td:first-child').map{|s| s.text}.should == %w'2 1'
655
655
 
656
656
  click_link 'Delete'
657
- all('option').map{|s| s.text}.should == ['', '2', '1']
657
+ page.all('option').map{|s| s.text}.should == ['', '2', '1']
658
658
  select '1'
659
659
  click_button 'Delete'
660
660
  end
@@ -676,9 +676,9 @@ describe AutoForme do
676
676
  fill_in 'Num', :with=>'1.01'
677
677
  click_button 'Create'
678
678
  click_link 'Artist'
679
- all('tr td:first-child').map{|s| s.text}.should == %w'1.01'
679
+ page.all('tr td:first-child').map{|s| s.text}.should == %w'1.01'
680
680
  click_link 'Search'
681
681
  click_button 'Search'
682
- all('tr td:first-child').map{|s| s.text}.should == %w'1.01'
682
+ page.all('tr td:first-child').map{|s| s.text}.should == %w'1.01'
683
683
  end
684
684
  end
@@ -41,23 +41,23 @@ describe AutoForme do
41
41
  click_button "Edit"
42
42
 
43
43
  find('h2').text.should == 'Edit Albums for Artist1'
44
- all('select')[0].all('option').map{|s| s.text}.should == ["Album1", "Album2", "Album3"]
45
- all('select')[1].all('option').map{|s| s.text}.should == []
44
+ page.all('select')[0].all('option').map{|s| s.text}.should == ["Album1", "Album2", "Album3"]
45
+ page.all('select')[1].all('option').map{|s| s.text}.should == []
46
46
  select("Album1", :from=>"Associate With")
47
47
  click_button "Update"
48
48
  page.html.should =~ /Updated albums association for Artist/
49
49
  Artist.first.albums.map{|x| x.name}.should == %w'Album1'
50
50
 
51
- all('select')[0].all('option').map{|s| s.text}.should == ["Album2", "Album3"]
52
- all('select')[1].all('option').map{|s| s.text}.should == ["Album1"]
51
+ page.all('select')[0].all('option').map{|s| s.text}.should == ["Album2", "Album3"]
52
+ page.all('select')[1].all('option').map{|s| s.text}.should == ["Album1"]
53
53
  select("Album2", :from=>"Associate With")
54
54
  select("Album3", :from=>"Associate With")
55
55
  select("Album1", :from=>"Disassociate From")
56
56
  click_button "Update"
57
57
  Artist.first.refresh.albums.map{|x| x.name}.should == %w'Album2 Album3'
58
58
 
59
- all('select')[0].all('option').map{|s| s.text}.should == ["Album1"]
60
- all('select')[1].all('option').map{|s| s.text}.should == ["Album2", "Album3"]
59
+ page.all('select')[0].all('option').map{|s| s.text}.should == ["Album1"]
60
+ page.all('select')[1].all('option').map{|s| s.text}.should == ["Album2", "Album3"]
61
61
  end
62
62
 
63
63
  it "should have many to many association editing working with autocompletion" do
@@ -79,23 +79,23 @@ describe AutoForme do
79
79
  select("Artist1")
80
80
  click_button "Edit"
81
81
 
82
- all('select')[0].all('option').map{|s| s.text}.should == []
82
+ page.all('select')[0].all('option').map{|s| s.text}.should == []
83
83
  fill_in "Associate With", :with=>a1.id
84
84
  click_button "Update"
85
85
  page.html.should =~ /Updated albums association for Artist/
86
86
  Artist.first.albums.map{|x| x.name}.should == %w'Album1'
87
87
 
88
- all('select')[0].all('option').map{|s| s.text}.should == ["Album1"]
88
+ page.all('select')[0].all('option').map{|s| s.text}.should == ["Album1"]
89
89
  fill_in "Associate With", :with=>a2.id
90
90
  select("Album1", :from=>"Disassociate From")
91
91
  click_button "Update"
92
92
  Artist.first.refresh.albums.map{|x| x.name}.should == %w'Album2'
93
93
 
94
- all('select')[0].all('option').map{|s| s.text}.should == ["Album2"]
94
+ page.all('select')[0].all('option').map{|s| s.text}.should == ["Album2"]
95
95
  select("Album2", :from=>"Disassociate From")
96
96
  click_button "Update"
97
97
  Artist.first.refresh.albums.map{|x| x.name}.should == []
98
- all('select')[0].all('option').map{|s| s.text}.should == []
98
+ page.all('select')[0].all('option').map{|s| s.text}.should == []
99
99
  end
100
100
 
101
101
  it "should have inline many to many association editing working" do
@@ -219,22 +219,22 @@ describe AutoForme do
219
219
  select("Artist1")
220
220
  click_button "Edit"
221
221
 
222
- all('select')[0].all('option').map{|s| s.text}.should == ["Album1", "Album2", "Album3"]
223
- all('select')[1].all('option').map{|s| s.text}.should == []
222
+ page.all('select')[0].all('option').map{|s| s.text}.should == ["Album1", "Album2", "Album3"]
223
+ page.all('select')[1].all('option').map{|s| s.text}.should == []
224
224
  select("Album1", :from=>"Associate With")
225
225
  click_button "Update"
226
226
  Artist.first.refresh.albums.map{|x| x.name}.should == %w'Album1'
227
227
 
228
- all('select')[0].all('option').map{|s| s.text}.should == ["Album2", "Album3"]
229
- all('select')[1].all('option').map{|s| s.text}.should == ["Album1"]
228
+ page.all('select')[0].all('option').map{|s| s.text}.should == ["Album2", "Album3"]
229
+ page.all('select')[1].all('option').map{|s| s.text}.should == ["Album1"]
230
230
  select("Album2", :from=>"Associate With")
231
231
  select("Album3", :from=>"Associate With")
232
232
  select("Album1", :from=>"Disassociate From")
233
233
  click_button "Update"
234
234
  Artist.first.refresh.albums.map{|x| x.name}.should == %w'Album2 Album3'
235
235
 
236
- all('select')[0].all('option').map{|s| s.text}.should == ["Album1"]
237
- all('select')[1].all('option').map{|s| s.text}.should == ["Album2", "Album3"]
236
+ page.all('select')[0].all('option').map{|s| s.text}.should == ["Album1"]
237
+ page.all('select')[1].all('option').map{|s| s.text}.should == ["Album2", "Album3"]
238
238
  end
239
239
 
240
240
  it "should use filter/order from associated class" do
@@ -257,21 +257,21 @@ describe AutoForme do
257
257
  select("Artist1")
258
258
  click_button "Edit"
259
259
 
260
- all('select')[0].all('option').map{|s| s.text}.should == ["B1", "E1"]
261
- all('select')[1].all('option').map{|s| s.text}.should == []
260
+ page.all('select')[0].all('option').map{|s| s.text}.should == ["B1", "E1"]
261
+ page.all('select')[1].all('option').map{|s| s.text}.should == []
262
262
  select("E1", :from=>"Associate With")
263
263
  click_button "Update"
264
264
  Artist.first.albums.map{|x| x.name}.should == %w'E1'
265
265
 
266
- all('select')[0].all('option').map{|s| s.text}.should == ["B1"]
267
- all('select')[1].all('option').map{|s| s.text}.should == ["E1"]
266
+ page.all('select')[0].all('option').map{|s| s.text}.should == ["B1"]
267
+ page.all('select')[1].all('option').map{|s| s.text}.should == ["E1"]
268
268
  select("B1", :from=>"Associate With")
269
269
  select("E1", :from=>"Disassociate From")
270
270
  click_button "Update"
271
271
  Artist.first.refresh.albums.map{|x| x.name}.should == %w'B1'
272
272
 
273
- all('select')[0].all('option').map{|s| s.text}.should == ["E1"]
274
- all('select')[1].all('option').map{|s| s.text}.should == ["B1"]
273
+ page.all('select')[0].all('option').map{|s| s.text}.should == ["E1"]
274
+ page.all('select')[1].all('option').map{|s| s.text}.should == ["B1"]
275
275
 
276
276
  select("B1", :from=>"Disassociate From")
277
277
  Album.where(:name=>'B1').update(:name=>'Z1')
@@ -287,8 +287,8 @@ describe AutoForme do
287
287
  visit('/Artist/mtm_edit')
288
288
  select("Artist1")
289
289
  click_button "Edit"
290
- all('select')[0].all('option').map{|s| s.text}.should == []
291
- all('select')[1].all('option').map{|s| s.text}.should == []
290
+ page.all('select')[0].all('option').map{|s| s.text}.should == []
291
+ page.all('select')[1].all('option').map{|s| s.text}.should == []
292
292
  end
293
293
 
294
294
  it "should support column options on mtm_edit page" do
@@ -359,22 +359,22 @@ describe AutoForme do
359
359
  click_button "Edit"
360
360
 
361
361
  find('h2').text.should == 'Edit Albums for Artist1'
362
- all('select')[0].all('option').map{|s| s.text}.should == ["Album1", "Album2", "Album3"]
363
- all('select')[1].all('option').map{|s| s.text}.should == []
362
+ page.all('select')[0].all('option').map{|s| s.text}.should == ["Album1", "Album2", "Album3"]
363
+ page.all('select')[1].all('option').map{|s| s.text}.should == []
364
364
  select("Album1", :from=>"Associate With")
365
365
  click_button "Update"
366
366
  page.html.should =~ /Updated albums association for Artist/
367
367
  Artist.first.albums.map{|x| x.name}.should == %w'Album1'
368
368
 
369
- all('select')[0].all('option').map{|s| s.text}.should == ["Album2", "Album3"]
370
- all('select')[1].all('option').map{|s| s.text}.should == ["Album1"]
369
+ page.all('select')[0].all('option').map{|s| s.text}.should == ["Album2", "Album3"]
370
+ page.all('select')[1].all('option').map{|s| s.text}.should == ["Album1"]
371
371
  select("Album2", :from=>"Associate With")
372
372
  select("Album3", :from=>"Associate With")
373
373
  select("Album1", :from=>"Disassociate From")
374
374
  click_button "Update"
375
375
  Artist.first.refresh.albums.map{|x| x.name}.should == %w'Album2 Album3'
376
376
 
377
- all('select')[0].all('option').map{|s| s.text}.should == ["Album1"]
378
- all('select')[1].all('option').map{|s| s.text}.should == ["Album2", "Album3"]
377
+ page.all('select')[0].all('option').map{|s| s.text}.should == ["Album1"]
378
+ page.all('select')[1].all('option').map{|s| s.text}.should == ["Album2", "Album3"]
379
379
  end
380
380
  end
@@ -22,7 +22,8 @@ HTML
22
22
  use Rack::Session::Cookie, :secret => '1'
23
23
  use Rack::Csrf
24
24
 
25
- plugin :render, :layout=>{:inline=>LAYOUT}
25
+ plugin :static_path_info unless ENV['RODA_NO_STATIC_PATH_INFO']
26
+ plugin :render, :layout=>{:inline=>LAYOUT}, :opts=>{:default_encoding=>nil}
26
27
  plugin :not_found do
27
28
  'Unhandled Request'
28
29
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: autoforme
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Evans
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-19 00:00:00.000000000 Z
11
+ date: 2014-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: forme
@@ -125,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
125
  version: '0'
126
126
  requirements: []
127
127
  rubyforge_project:
128
- rubygems_version: 2.2.2
128
+ rubygems_version: 2.4.4
129
129
  signing_key:
130
130
  specification_version: 4
131
131
  summary: Web Administrative Console for Sinatra/Rails and Sequel