autoforme 1.9.1 → 1.12.0

Sign up to get free protection for your applications and to get access to all the features.
data/spec/mtm_spec.rb DELETED
@@ -1,509 +0,0 @@
1
- require './spec/spec_helper'
2
-
3
- describe AutoForme do
4
- before(:all) do
5
- db_setup(:artists=>[[:name, :string]], :albums=>[[:name, :string]], :albums_artists=>[[:album_id, :integer, {:table=>:albums}], [:artist_id, :integer, {:table=>:artists}]])
6
- model_setup(:Artist=>[:artists, [[:many_to_many, :albums]]], :Album=>[:albums, [[:many_to_many, :artists]]])
7
- end
8
- after(:all) do
9
- Object.send(:remove_const, :Album)
10
- Object.send(:remove_const, :Artist)
11
- end
12
-
13
- it "should not show MTM link if there are no many to many associations" do
14
- app_setup do
15
- model Artist
16
- model Album
17
- end
18
-
19
- visit("/Artist/browse")
20
- page.html.wont_include 'MTM'
21
- visit("/Artist/mtm_edit")
22
- page.html.must_include 'Unhandled Request'
23
- end
24
-
25
- it "should have working Model#associated_object_display_name" do
26
- mod = nil
27
- app_setup do
28
- model Artist
29
- model Album do
30
- mod = self
31
- end
32
- end
33
-
34
- mod.associated_object_display_name(:artist, nil, Artist.load(:name=>'a')).must_equal 'a'
35
- end
36
-
37
- it "should have Model#associated_object_display_name respect :name_method column option" do
38
- mod = nil
39
- app_setup do
40
- model Artist
41
- model Album do
42
- column_options :artist=>{:name_method=>:id}
43
- mod = self
44
- end
45
- end
46
-
47
- mod.associated_object_display_name(:artist, nil, Artist.load(:id=>1)).must_equal 1
48
- end
49
-
50
- it "should have Model#associated_object_display_name raise Error if not valid" do
51
- mod = nil
52
- app_setup do
53
- model Artist
54
- model Album do
55
- column_options :artist=>{:name_method=>Object.new}
56
- mod = self
57
- end
58
- end
59
-
60
- proc{mod.associated_object_display_name(:artist, nil, Artist.load(:name=>'a'))}.must_raise AutoForme::Error
61
- end
62
-
63
- it "should have basic many to many association editing working" do
64
- app_setup do
65
- model Artist do
66
- mtm_associations :albums
67
- end
68
- model Album
69
- end
70
-
71
- Artist.create(:name=>'Artist1')
72
- Album.create(:name=>'Album1')
73
- Album.create(:name=>'Album2')
74
- Album.create(:name=>'Album3')
75
-
76
- visit("/Artist/mtm_edit")
77
- page.title.must_equal 'Artist - Many To Many Edit'
78
- click_button "Edit"
79
- select("Artist1")
80
- click_button "Edit"
81
-
82
- find('h2').text.must_equal 'Edit Albums for Artist1'
83
- page.all('select')[0].all('option').map{|s| s.text}.must_equal ["Album1", "Album2", "Album3"]
84
- page.all('select')[1].all('option').map{|s| s.text}.must_equal []
85
- select("Album1", :from=>"Associate With")
86
- click_button "Update"
87
- page.html.must_include 'Updated albums association for Artist'
88
- Artist.first.albums.map{|x| x.name}.must_equal %w'Album1'
89
-
90
- page.all('select')[0].all('option').map{|s| s.text}.must_equal ["Album2", "Album3"]
91
- page.all('select')[1].all('option').map{|s| s.text}.must_equal ["Album1"]
92
- select("Album2", :from=>"Associate With")
93
- select("Album3", :from=>"Associate With")
94
- select("Album1", :from=>"Disassociate From")
95
- click_button "Update"
96
- Artist.first.refresh.albums.map{|x| x.name}.must_equal %w'Album2 Album3'
97
-
98
- page.all('select')[0].all('option').map{|s| s.text}.must_equal ["Album1"]
99
- page.all('select')[1].all('option').map{|s| s.text}.must_equal ["Album2", "Album3"]
100
- end
101
-
102
- it "should have many to many association editing working with autocompletion" do
103
- app_setup do
104
- model Artist do
105
- mtm_associations :albums
106
- end
107
- model Album do
108
- autocomplete_options({})
109
- end
110
- end
111
-
112
- Artist.create(:name=>'Artist1')
113
- a1 = Album.create(:name=>'Album1')
114
- a2 = Album.create(:name=>'Album2')
115
- a3 = Album.create(:name=>'Album3')
116
-
117
- visit("/Artist/mtm_edit")
118
- select("Artist1")
119
- click_button "Edit"
120
-
121
- page.all('select')[0].all('option').map{|s| s.text}.must_equal []
122
- fill_in "Associate With", :with=>a1.id
123
- click_button "Update"
124
- page.html.must_include 'Updated albums association for Artist'
125
- Artist.first.albums.map{|x| x.name}.must_equal %w'Album1'
126
-
127
- page.all('select')[0].all('option').map{|s| s.text}.must_equal ["Album1"]
128
- fill_in "Associate With", :with=>a2.id
129
- select("Album1", :from=>"Disassociate From")
130
- click_button "Update"
131
- Artist.first.refresh.albums.map{|x| x.name}.must_equal %w'Album2'
132
-
133
- visit "/Artist/autocomplete/albums?type=association&q=Album"
134
- page.body.must_match(/#{a1.id} - Album1\n#{a2.id} - Album2\n#{a3.id} - Album3/m)
135
-
136
- visit "/Artist/autocomplete/albums?type=association&q=3"
137
- page.body.wont_match(/#{a1.id} - Album1\n#{a2.id} - Album2\n#{a3.id} - Album3/m)
138
- page.body.must_match(/#{a3.id} - Album3/m)
139
-
140
- visit "/Artist/autocomplete/albums?type=association&exclude=#{Artist.first.id}&q=Album"
141
- page.body.must_match(/#{a1.id} - Album1\n#{a3.id} - Album3/m)
142
-
143
- visit("/Artist/mtm_edit")
144
- select("Artist1")
145
- click_button "Edit"
146
- page.all('select')[0].all('option').map{|s| s.text}.must_equal ["Album2"]
147
- select("Album2", :from=>"Disassociate From")
148
- click_button "Update"
149
- Artist.first.refresh.albums.map{|x| x.name}.must_equal []
150
- page.all('select')[0].all('option').map{|s| s.text}.must_equal []
151
- end
152
-
153
- it "should have inline many to many association editing working" do
154
- app_setup do
155
- model Artist do
156
- inline_mtm_associations :albums
157
- end
158
- model Album
159
- end
160
-
161
- Artist.create(:name=>'Artist1')
162
- Album.create(:name=>'Album1')
163
- Album.create(:name=>'Album2')
164
- Album.create(:name=>'Album3')
165
-
166
- visit("/Artist/edit")
167
- select("Artist1")
168
- click_button "Edit"
169
- select 'Album1'
170
- click_button 'Add'
171
- page.html.must_include 'Updated albums association for Artist'
172
- Artist.first.albums.map{|x| x.name}.must_equal %w'Album1'
173
-
174
- select 'Album2'
175
- click_button 'Add'
176
- Artist.first.refresh.albums.map{|x| x.name}.sort.must_equal %w'Album1 Album2'
177
-
178
- click_button 'Remove', :match=>:first
179
- Artist.first.refresh.albums.map{|x| x.name}.must_equal %w'Album2'
180
-
181
- select 'Album3'
182
- click_button 'Add'
183
- Artist.first.refresh.albums.map{|x| x.name}.sort.must_equal %w'Album2 Album3'
184
- end
185
-
186
- it "should have inline many to many association editing working with autocompletion" do
187
- app_setup do
188
- model Artist do
189
- inline_mtm_associations :albums
190
- end
191
- model Album do
192
- autocomplete_options({})
193
- end
194
- end
195
-
196
- Artist.create(:name=>'Artist1')
197
- a1 = Album.create(:name=>'Album1')
198
- a2 = Album.create(:name=>'Album2')
199
- a3 = Album.create(:name=>'Album3')
200
-
201
- visit("/Artist/edit")
202
- select("Artist1")
203
- click_button "Edit"
204
- fill_in 'Albums', :with=>a1.id.to_s
205
- click_button 'Add'
206
- page.html.must_include 'Updated albums association for Artist'
207
- Artist.first.albums.map{|x| x.name}.must_equal %w'Album1'
208
-
209
- fill_in 'Albums', :with=>a2.id.to_s
210
- click_button 'Add'
211
- Artist.first.refresh.albums.map{|x| x.name}.sort.must_equal %w'Album1 Album2'
212
-
213
- click_button 'Remove', :match=>:first
214
- Artist.first.refresh.albums.map{|x| x.name}.must_equal %w'Album2'
215
-
216
- fill_in 'Albums', :with=>a3.id.to_s
217
- click_button 'Add'
218
- Artist.first.refresh.albums.map{|x| x.name}.sort.must_equal %w'Album2 Album3'
219
- end
220
-
221
- it "should have inline many to many association editing working with xhr" do
222
- app_setup do
223
- model Artist do
224
- inline_mtm_associations do |req|
225
- def req.xhr?; action_type == 'mtm_update' end
226
- :albums
227
- end
228
- end
229
- model Album
230
- end
231
-
232
- Artist.create(:name=>'Artist1')
233
- album = Album.create(:name=>'Album1')
234
-
235
- visit("/Artist/edit")
236
- select("Artist1")
237
- click_button "Edit"
238
- select 'Album1'
239
- click_button 'Add'
240
- Artist.first.albums.map{|x| x.name}.must_equal %w'Album1'
241
-
242
- click_button 'Remove'
243
- Artist.first.refresh.albums.map{|x| x.name}.must_equal []
244
- page.body.must_equal "<option value=\"#{album.id}\">Album1</option>"
245
- end
246
-
247
- it "should have working many to many association links on show and edit pages" do
248
- app_setup do
249
- model Artist do
250
- mtm_associations :albums
251
- association_links :all_except_mtm
252
- end
253
- model Album do
254
- mtm_associations [:artists]
255
- association_links :all
256
- end
257
- end
258
-
259
- visit("/Artist/new")
260
- fill_in 'Name', :with=>'Artist1'
261
- click_button 'Create'
262
- click_link 'Edit'
263
- select 'Artist1'
264
- click_button 'Edit'
265
- page.html.wont_include 'Albums'
266
-
267
- visit("/Album/new")
268
- fill_in 'Name', :with=>'Album1'
269
- click_button 'Create'
270
- click_link 'Edit'
271
- select 'Album1'
272
- click_button 'Edit'
273
- click_link 'associate'
274
- select("Artist1", :from=>"Associate With")
275
- click_button 'Update'
276
- click_link 'Show'
277
- select 'Album1'
278
- click_button 'Show'
279
- click_link 'Artist1'
280
- page.current_path.must_match %r{Artist/show/\d+}
281
- page.html.wont_include 'Albums'
282
- end
283
-
284
- it "should have many to many association editing working when associated class is not using autoforme" do
285
- app_setup do
286
- model Artist do
287
- mtm_associations [:albums]
288
- end
289
- end
290
-
291
- Artist.create(:name=>'Artist1')
292
- Album.create(:name=>'Album1')
293
- Album.create(:name=>'Album2')
294
- Album.create(:name=>'Album3')
295
-
296
- visit("/Artist/mtm_edit")
297
- select("Artist1")
298
- click_button "Edit"
299
-
300
- page.all('select')[0].all('option').map{|s| s.text}.must_equal ["Album1", "Album2", "Album3"]
301
- page.all('select')[1].all('option').map{|s| s.text}.must_equal []
302
- select("Album1", :from=>"Associate With")
303
- click_button "Update"
304
- Artist.first.refresh.albums.map{|x| x.name}.must_equal %w'Album1'
305
-
306
- page.all('select')[0].all('option').map{|s| s.text}.must_equal ["Album2", "Album3"]
307
- page.all('select')[1].all('option').map{|s| s.text}.must_equal ["Album1"]
308
- select("Album2", :from=>"Associate With")
309
- select("Album3", :from=>"Associate With")
310
- select("Album1", :from=>"Disassociate From")
311
- click_button "Update"
312
- Artist.first.refresh.albums.map{|x| x.name}.must_equal %w'Album2 Album3'
313
-
314
- page.all('select')[0].all('option').map{|s| s.text}.must_equal ["Album1"]
315
- page.all('select')[1].all('option').map{|s| s.text}.must_equal ["Album2", "Album3"]
316
- end
317
-
318
- it "should use filter/order from associated class" do
319
- app_setup do
320
- model Artist do
321
- mtm_associations :all
322
- end
323
- model Album do
324
- filter{|ds, req| ds.where(:name=>'A'..'M')}
325
- order :name
326
- end
327
- end
328
-
329
- Artist.create(:name=>'Artist1')
330
- Album.create(:name=>'E1')
331
- Album.create(:name=>'B1')
332
- Album.create(:name=>'O1')
333
-
334
- visit("/Artist/mtm_edit")
335
- select("Artist1")
336
- click_button "Edit"
337
-
338
- page.all('select')[0].all('option').map{|s| s.text}.must_equal ["B1", "E1"]
339
- page.all('select')[1].all('option').map{|s| s.text}.must_equal []
340
- select("E1", :from=>"Associate With")
341
- click_button "Update"
342
- Artist.first.albums.map{|x| x.name}.must_equal %w'E1'
343
-
344
- page.all('select')[0].all('option').map{|s| s.text}.must_equal ["B1"]
345
- page.all('select')[1].all('option').map{|s| s.text}.must_equal ["E1"]
346
- select("B1", :from=>"Associate With")
347
- select("E1", :from=>"Disassociate From")
348
- click_button "Update"
349
- Artist.first.refresh.albums.map{|x| x.name}.must_equal %w'B1'
350
-
351
- page.all('select')[0].all('option').map{|s| s.text}.must_equal ["E1"]
352
- page.all('select')[1].all('option').map{|s| s.text}.must_equal ["B1"]
353
-
354
- select("B1", :from=>"Disassociate From")
355
- Album.where(:name=>'B1').update(:name=>'Z1')
356
- proc{click_button "Update"}.must_raise(Sequel::NoMatchingRow)
357
-
358
- visit('/Artist/mtm_edit')
359
- select("Artist1")
360
- click_button "Edit"
361
- select("E1", :from=>"Associate With")
362
- Album.where(:name=>'E1').update(:name=>'Y1')
363
- proc{click_button "Update"}.must_raise(Sequel::NoMatchingRow)
364
-
365
- visit('/Artist/mtm_edit')
366
- select("Artist1")
367
- click_button "Edit"
368
- page.all('select')[0].all('option').map{|s| s.text}.must_equal []
369
- page.all('select')[1].all('option').map{|s| s.text}.must_equal []
370
- end
371
-
372
- it "should support column options on mtm_edit page" do
373
- app_setup do
374
- model Artist do
375
- mtm_associations :albums
376
- column_options :albums=>{:as=>:checkbox, :remove=>{:name_method=>proc{|obj| obj.name * 2}}}
377
- end
378
- model Album do
379
- display_name{|obj, req| obj.name + "2"}
380
- end
381
- end
382
-
383
- Artist.create(:name=>'Artist1')
384
- Album.create(:name=>'Album1')
385
- Album.create(:name=>'Album2')
386
- Album.create(:name=>'Album3')
387
-
388
- visit("/Artist/mtm_edit")
389
- select("Artist1")
390
- click_button "Edit"
391
-
392
- check "Album12"
393
- click_button "Update"
394
- Artist.first.albums.map{|x| x.name}.must_equal %w'Album1'
395
-
396
- check "Album1Album1"
397
- check "Album22"
398
- check "Album32"
399
- click_button "Update"
400
- Artist.first.refresh.albums.map{|x| x.name}.must_equal %w'Album2 Album3'
401
-
402
- check "Album12"
403
- check "Album2Album2"
404
- check "Album3Album3"
405
- end
406
- end
407
-
408
- describe AutoForme do
409
- before(:all) do
410
- db_setup(:artists=>proc{primary_key :artist_id; String :name}, :albums=>[[:name, :string]], :albums_artists=>[[:album_id, :integer, {:table=>:albums}], [:artist_id, :integer, {:table=>:artists}]])
411
- model_setup(:Artist=>[:artists, [[:many_to_many, :albums]]], :Album=>[:albums, [[:many_to_many, :artists]]])
412
- end
413
- after(:all) do
414
- Object.send(:remove_const, :Album)
415
- Object.send(:remove_const, :Artist)
416
- end
417
-
418
- it "should have basic many to many association editing working" do
419
- app_setup do
420
- model Artist do
421
- mtm_associations :albums
422
- end
423
- model Album
424
- end
425
-
426
- Artist.create(:name=>'Artist1')
427
- Album.create(:name=>'Album1')
428
- Album.create(:name=>'Album2')
429
- Album.create(:name=>'Album3')
430
-
431
- visit("/Artist/mtm_edit")
432
- page.title.must_equal 'Artist - Many To Many Edit'
433
- click_button "Edit"
434
- select("Artist1")
435
- click_button "Edit"
436
-
437
- find('h2').text.must_equal 'Edit Albums for Artist1'
438
- page.all('select')[0].all('option').map{|s| s.text}.must_equal ["Album1", "Album2", "Album3"]
439
- page.all('select')[1].all('option').map{|s| s.text}.must_equal []
440
- select("Album1", :from=>"Associate With")
441
- click_button "Update"
442
- page.html.must_include 'Updated albums association for Artist'
443
- Artist.first.albums.map{|x| x.name}.must_equal %w'Album1'
444
-
445
- page.all('select')[0].all('option').map{|s| s.text}.must_equal ["Album2", "Album3"]
446
- page.all('select')[1].all('option').map{|s| s.text}.must_equal ["Album1"]
447
- select("Album2", :from=>"Associate With")
448
- select("Album3", :from=>"Associate With")
449
- select("Album1", :from=>"Disassociate From")
450
- click_button "Update"
451
- Artist.first.refresh.albums.map{|x| x.name}.must_equal %w'Album2 Album3'
452
-
453
- page.all('select')[0].all('option').map{|s| s.text}.must_equal ["Album1"]
454
- page.all('select')[1].all('option').map{|s| s.text}.must_equal ["Album2", "Album3"]
455
- end
456
-
457
- end
458
-
459
- describe AutoForme do
460
- before(:all) do
461
- db_setup(:artists=>[[:name, :string]], :albums=>[[:name, :string]], :albums_artists=>[[:album_id, :integer, {:table=>:albums}], [:artist_id, :integer, {:table=>:artists}]])
462
- model_setup(:Artist=>[:artists, [[:many_to_many, :albums]], [[:many_to_many, :other_albums, {:clone=>:albums}]]], :Album=>[:albums, [[:many_to_many, :artists]]])
463
- end
464
- after(:all) do
465
- Object.send(:remove_const, :Album)
466
- Object.send(:remove_const, :Artist)
467
- end
468
-
469
- it "should have basic many to many association editing working" do
470
- app_setup do
471
- model Artist do
472
- mtm_associations [:albums, :other_albums]
473
- end
474
- model Album
475
- end
476
-
477
- Artist.create(:name=>'Artist1')
478
- Album.create(:name=>'Album1')
479
- Album.create(:name=>'Album2')
480
- Album.create(:name=>'Album3')
481
-
482
- visit("/Artist/mtm_edit")
483
- page.title.must_equal 'Artist - Many To Many Edit'
484
- select("Artist1")
485
- click_button "Edit"
486
-
487
- select('albums')
488
- click_button "Edit"
489
-
490
- find('h2').text.must_equal 'Edit Albums for Artist1'
491
- page.all('select')[0].all('option').map{|s| s.text}.must_equal ["Album1", "Album2", "Album3"]
492
- page.all('select')[1].all('option').map{|s| s.text}.must_equal []
493
- select("Album1", :from=>"Associate With")
494
- click_button "Update"
495
- page.html.must_include 'Updated albums association for Artist'
496
- Artist.first.albums.map{|x| x.name}.must_equal %w'Album1'
497
-
498
- page.all('select')[0].all('option').map{|s| s.text}.must_equal ["Album2", "Album3"]
499
- page.all('select')[1].all('option').map{|s| s.text}.must_equal ["Album1"]
500
- select("Album2", :from=>"Associate With")
501
- select("Album3", :from=>"Associate With")
502
- select("Album1", :from=>"Disassociate From")
503
- click_button "Update"
504
- Artist.first.refresh.albums.map{|x| x.name}.must_equal %w'Album2 Album3'
505
-
506
- page.all('select')[0].all('option').map{|s| s.text}.must_equal ["Album1"]
507
- page.all('select')[1].all('option').map{|s| s.text}.must_equal ["Album2", "Album3"]
508
- end
509
- end
@@ -1,78 +0,0 @@
1
- require 'rubygems'
2
- require 'action_controller/railtie'
3
- require 'autoforme'
4
-
5
- class AutoFormeSpec::App
6
- def self.autoforme(klass=nil, opts={}, &block)
7
- sc = Class.new(Rails::Application)
8
- def sc.name
9
- "AutoForme Test"
10
- end
11
- framework = nil
12
- sc.class_eval do
13
- controller = Class.new(ActionController::Base)
14
- Object.send(:const_set, :AutoformeController, controller)
15
-
16
- resolver = Class.new(ActionView::Resolver)
17
- resolver.class_eval do
18
- template = ActionView::Template
19
- t = [template.new(<<HTML, "layout", template.handler_for_extension(:erb), {:virtual_path=>'layout', :format=>'erb', :updated_at=>Time.now})]
20
- <!DOCTYPE html>
21
- <html>
22
- <head><title><%= @autoforme_action.title if @autoforme_action %></title></head>
23
- <body>
24
- <% if flash[:notice] %>
25
- <div class="alert alert-success"><p><%= flash[:notice] %></p></div>
26
- <% end %>
27
- <% if flash[:error] %>
28
- <div class="alert alert-error"><p><%= flash[:error] %></p></div>
29
- <% end %>
30
- <%= yield %>
31
- </body></html>"
32
- HTML
33
-
34
- define_method(:find_templates){|*args| t}
35
- end
36
-
37
- controller.class_eval do
38
- self.view_paths = resolver.new
39
- layout 'layout'
40
-
41
- def session_set
42
- params.each{|k,v| session[k] = v}
43
- render :plain=>''
44
- end
45
-
46
- AutoForme.for(:rails, self, opts) do
47
- framework = self
48
- if klass
49
- model(klass, &block)
50
- elsif block
51
- instance_eval(&block)
52
- end
53
- end
54
- end
55
-
56
- st = routes.append do
57
- get 'session/set', :controller=>'autoforme', :action=>'session_set'
58
- end.inspect
59
- config.secret_token = st if Rails.respond_to?(:version) && Rails.version < '5.2'
60
- config.active_support.deprecation = :stderr
61
- config.middleware.delete(ActionDispatch::ShowExceptions)
62
- config.middleware.delete(Rack::Lock)
63
- config.secret_key_base = st*15
64
- config.eager_load = true
65
- if Rails.version > '4.2'
66
- config.action_dispatch.cookies_serializer = :json
67
- end
68
- if Rails.version > '5'
69
- # Force Rails to dispatch to correct controller
70
- ActionDispatch::Routing::RouteSet::Dispatcher.class_eval do
71
- define_method(:controller){|_| controller}
72
- end
73
- end
74
- initialize!
75
- end
76
- [sc, framework]
77
- end
78
- end
data/spec/roda_spec.rb DELETED
@@ -1,72 +0,0 @@
1
- require './spec/spec_helper'
2
-
3
- describe AutoForme do
4
- before(:all) do
5
- db_setup(:artists=>[[:name, :string]])
6
- model_setup(:Artist=>[:artists])
7
- end
8
- after(:all) do
9
- Object.send(:remove_const, :Artist)
10
- end
11
-
12
- it "should have basic functionality working in Roda subclass" do
13
- app_setup(Artist)
14
- self.app = Class.new(app)
15
- visit("/Artist/new")
16
- page.title.must_equal 'Artist - New'
17
- fill_in 'Name', :with=>'TestArtistNew'
18
- click_button 'Create'
19
- page.html.must_include 'Created Artist'
20
- page.current_path.must_equal '/Artist/new'
21
-
22
- click_link 'Show'
23
- page.title.must_equal 'Artist - Show'
24
- click_button 'Show'
25
- select 'TestArtistNew'
26
- click_button 'Show'
27
- page.html.must_match(/Name.+TestArtistNew/m)
28
-
29
- click_link 'Edit'
30
- page.title.must_equal 'Artist - Edit'
31
- click_button 'Edit'
32
- select 'TestArtistNew'
33
- click_button 'Edit'
34
- fill_in 'Name', :with=>'TestArtistUpdate'
35
- click_button 'Update'
36
- page.html.must_include 'Updated Artist'
37
- page.html.must_match(/Name.+TestArtistUpdate/m)
38
- page.current_path.must_match %r{/Artist/edit/\d+}
39
-
40
- click_link 'Search'
41
- page.title.must_equal 'Artist - Search'
42
- fill_in 'Name', :with=>'Upd'
43
- click_button 'Search'
44
- page.all('table').first['id'].must_equal 'autoforme_table'
45
- page.all('th').map{|s| s.text}.must_equal ['Name', 'Show', 'Edit', 'Delete']
46
- page.all('td').map{|s| s.text}.must_equal ["TestArtistUpdate", "Show", "Edit", "Delete"]
47
- click_link 'CSV Format'
48
- page.body.must_equal "Name\nTestArtistUpdate\n"
49
-
50
- visit("/Artist/browse")
51
- click_link 'Search'
52
- fill_in 'Name', :with=>'Foo'
53
- click_button 'Search'
54
- page.all('td').map{|s| s.text}.must_equal []
55
-
56
- click_link 'Artist'
57
- page.title.must_equal 'Artist - Browse'
58
- page.all('td').map{|s| s.text}.must_equal ["TestArtistUpdate", "Show", "Edit", "Delete"]
59
- click_link 'CSV Format'
60
- page.body.must_equal "Name\nTestArtistUpdate\n"
61
-
62
- visit("/Artist/browse")
63
- page.all('td').last.find('a').click
64
- click_button 'Delete'
65
- page.title.must_equal 'Artist - Delete'
66
- page.html.must_include 'Deleted Artist'
67
- page.current_path.must_equal '/Artist/delete'
68
-
69
- click_link 'Artist'
70
- page.all('td').map{|s| s.text}.must_equal []
71
- end
72
- end if ENV['FRAMEWORK'] == 'roda'