autoforme 0.5.3 → 0.5.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +4 -0
- data/lib/autoforme/models/sequel.rb +1 -1
- data/lib/autoforme/version.rb +1 -1
- data/spec/associations_spec.rb +98 -0
- data/spec/sequel_spec_helper.rb +6 -0
- data/spec/unit_spec.rb +48 -48
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a6b8a4263970ea2e5bf3a985b8b4628af73c5f3
|
4
|
+
data.tar.gz: b5cc0a111748da7426f12d748e6a6a675395cbf7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8c36b982a6d2df2caafb06e3c9514cf2a69a9369ca2beb44fe9550c9774f4734ec84bbdc8d59d35557a9139909194f8019291c9dc1b0bc8f6e797799c23b876
|
7
|
+
data.tar.gz: 47abfeb25954620e28aaadd6cc9f90958326f2009db8495e2a25f8deb58af93a06d10ac6abc7b9d29267bca9d2a534d0cb8c1416076dee95895d3c0354dc466f
|
data/CHANGELOG
CHANGED
@@ -170,7 +170,7 @@ module AutoForme
|
|
170
170
|
ads = model_class.apply_filter(:association, request, ads)
|
171
171
|
end
|
172
172
|
primary_key = S.qualify(ref.associated_class.table_name, ref.primary_key)
|
173
|
-
ds = ds.where(ref[:key]=>ads.where(primary_key=>v).select(primary_key))
|
173
|
+
ds = ds.where(S.qualify(model.table_name, ref[:key])=>ads.where(primary_key=>v).select(primary_key))
|
174
174
|
elsif column_type(c) == :string
|
175
175
|
ds = ds.where(S.ilike(S.qualify(model.table_name, c), "%#{ds.escape_like(v.to_s)}%"))
|
176
176
|
else
|
data/lib/autoforme/version.rb
CHANGED
data/spec/associations_spec.rb
CHANGED
@@ -475,6 +475,104 @@ describe AutoForme do
|
|
475
475
|
end
|
476
476
|
end
|
477
477
|
|
478
|
+
describe AutoForme do
|
479
|
+
before(:all) do
|
480
|
+
db_setup(:artists=>[[:name, :string], [:artist_id, :integer]], :albums=>[[:name, :string], [:artist_id, :integer, {:table=>:artists}]])
|
481
|
+
model_setup(:Artist=>[:artists, [[:one_to_many, :albums]]], :Album=>[:albums, [[:many_to_one, :artist]]])
|
482
|
+
end
|
483
|
+
after(:all) do
|
484
|
+
Object.send(:remove_const, :Album)
|
485
|
+
Object.send(:remove_const, :Artist)
|
486
|
+
end
|
487
|
+
|
488
|
+
it "should have basic many to one associations working" do
|
489
|
+
app_setup do
|
490
|
+
model Artist
|
491
|
+
model Album do
|
492
|
+
columns [:name, :artist]
|
493
|
+
eager_graph :artist
|
494
|
+
order :artist__name
|
495
|
+
end
|
496
|
+
end
|
497
|
+
|
498
|
+
visit("/Artist/new")
|
499
|
+
fill_in 'Name', :with=>'Artist1'
|
500
|
+
click_button 'Create'
|
501
|
+
fill_in 'Name', :with=>'Artist2'
|
502
|
+
click_button 'Create'
|
503
|
+
|
504
|
+
visit("/Album/new")
|
505
|
+
fill_in 'Name', :with=>'Album1'
|
506
|
+
click_button 'Create'
|
507
|
+
|
508
|
+
click_link 'Edit'
|
509
|
+
select 'Album1'
|
510
|
+
click_button 'Edit'
|
511
|
+
fill_in 'Name', :with=>'Album1b'
|
512
|
+
select 'Artist2'
|
513
|
+
click_button 'Update'
|
514
|
+
|
515
|
+
click_link 'Show'
|
516
|
+
select 'Album1'
|
517
|
+
click_button 'Show'
|
518
|
+
page.html.should =~ /Name.+Album1b/m
|
519
|
+
page.html.should =~ /Artist.+Artist2/m
|
520
|
+
|
521
|
+
click_link 'Search'
|
522
|
+
fill_in 'Name', :with=>'1b'
|
523
|
+
select 'Artist2'
|
524
|
+
click_button 'Search'
|
525
|
+
all('td').map{|s| s.text}.should == ["Album1b", "Artist2", "Show", "Edit", "Delete"]
|
526
|
+
|
527
|
+
click_link 'Album'
|
528
|
+
all('td').map{|s| s.text}.should == ["Album1b", "Artist2", "Show", "Edit", "Delete"]
|
529
|
+
end
|
530
|
+
|
531
|
+
it "should have basic many to one associations working" do
|
532
|
+
app_setup do
|
533
|
+
model Artist do
|
534
|
+
eager_graph :albums
|
535
|
+
order :albums__name
|
536
|
+
end
|
537
|
+
model Album do
|
538
|
+
columns [:name, :artist]
|
539
|
+
end
|
540
|
+
end
|
541
|
+
|
542
|
+
visit("/Artist/new")
|
543
|
+
fill_in 'Name', :with=>'Artist1'
|
544
|
+
click_button 'Create'
|
545
|
+
fill_in 'Name', :with=>'Artist2'
|
546
|
+
click_button 'Create'
|
547
|
+
|
548
|
+
visit("/Album/new")
|
549
|
+
fill_in 'Name', :with=>'Album1'
|
550
|
+
click_button 'Create'
|
551
|
+
|
552
|
+
click_link 'Edit'
|
553
|
+
select 'Album1'
|
554
|
+
click_button 'Edit'
|
555
|
+
fill_in 'Name', :with=>'Album1b'
|
556
|
+
select 'Artist2'
|
557
|
+
click_button 'Update'
|
558
|
+
|
559
|
+
click_link 'Show'
|
560
|
+
select 'Album1'
|
561
|
+
click_button 'Show'
|
562
|
+
page.html.should =~ /Name.+Album1b/m
|
563
|
+
page.html.should =~ /Artist.+Artist2/m
|
564
|
+
|
565
|
+
click_link 'Search'
|
566
|
+
fill_in 'Name', :with=>'1b'
|
567
|
+
select 'Artist2'
|
568
|
+
click_button 'Search'
|
569
|
+
all('td').map{|s| s.text}.should == ["Album1b", "Artist2", "Show", "Edit", "Delete"]
|
570
|
+
|
571
|
+
click_link 'Album'
|
572
|
+
all('td').map{|s| s.text}.should == ["Album1b", "Artist2", "Show", "Edit", "Delete"]
|
573
|
+
end
|
574
|
+
end
|
575
|
+
|
478
576
|
describe AutoForme do
|
479
577
|
before(:all) do
|
480
578
|
db_setup(:artists=>[[:name, :string]], :albums=>[[:name, :string], [:artist_id, :integer, {:table=>:artists}]])
|
data/spec/sequel_spec_helper.rb
CHANGED
@@ -1,8 +1,14 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'sequel'
|
3
3
|
require 'logger'
|
4
|
+
require 'rspec/version'
|
4
5
|
|
5
6
|
RSpec.configure do |c|
|
7
|
+
if RSpec::Version::STRING >= '2.11.0'
|
8
|
+
c.expect_with :rspec do |c1|
|
9
|
+
c1.syntax = :should
|
10
|
+
end
|
11
|
+
end
|
6
12
|
c.around(:each) do |example|
|
7
13
|
if db
|
8
14
|
db.transaction(:rollback=>:always){example.run}
|
data/spec/unit_spec.rb
CHANGED
@@ -132,65 +132,65 @@ describe AutoForme do
|
|
132
132
|
end
|
133
133
|
|
134
134
|
it "should handle supported_actions lookup" do
|
135
|
-
model.supported_action?(:new, nil).should
|
136
|
-
model.supported_action?(:edit, nil).should
|
137
|
-
model.supported_action?(:search, nil).should
|
135
|
+
model.supported_action?(:new, nil).should == true
|
136
|
+
model.supported_action?(:edit, nil).should == true
|
137
|
+
model.supported_action?(:search, nil).should == true
|
138
138
|
framework.supported_actions [:new, :search]
|
139
|
-
model.supported_action?(:new, nil).should
|
140
|
-
model.supported_action?(:edit, nil).should
|
141
|
-
model.supported_action?(:search, nil).should
|
139
|
+
model.supported_action?(:new, nil).should == true
|
140
|
+
model.supported_action?(:edit, nil).should == false
|
141
|
+
model.supported_action?(:search, nil).should == true
|
142
142
|
framework.supported_actions{|mod, req| req ? [:new] : []}
|
143
|
-
model.supported_action?(:new, nil).should
|
144
|
-
model.supported_action?(:new, true).should
|
143
|
+
model.supported_action?(:new, nil).should == false
|
144
|
+
model.supported_action?(:new, true).should == true
|
145
145
|
model.supported_actions [:edit, :search]
|
146
|
-
model.supported_action?(:new, nil).should
|
147
|
-
model.supported_action?(:edit, nil).should
|
148
|
-
model.supported_action?(:search, nil).should
|
146
|
+
model.supported_action?(:new, nil).should == false
|
147
|
+
model.supported_action?(:edit, nil).should == true
|
148
|
+
model.supported_action?(:search, nil).should == true
|
149
149
|
model.supported_actions{|req| req ? [:new] : []}
|
150
|
-
model.supported_action?(:new, nil).should
|
151
|
-
model.supported_action?(:new, true).should
|
150
|
+
model.supported_action?(:new, nil).should == false
|
151
|
+
model.supported_action?(:new, true).should == true
|
152
152
|
end
|
153
153
|
|
154
154
|
it "should handle mtm_associations lookup" do
|
155
|
-
model.supported_mtm_edit?('foos', nil).should
|
156
|
-
model.supported_mtm_edit?('bars', nil).should
|
155
|
+
model.supported_mtm_edit?('foos', nil).should == false
|
156
|
+
model.supported_mtm_edit?('bars', nil).should == false
|
157
157
|
framework.mtm_associations [:foos]
|
158
|
-
model.supported_mtm_edit?('foos', nil).should
|
159
|
-
model.supported_mtm_edit?('bars', nil).should
|
158
|
+
model.supported_mtm_edit?('foos', nil).should == true
|
159
|
+
model.supported_mtm_edit?('bars', nil).should == false
|
160
160
|
framework.mtm_associations{|mod, req| req ? [:foos] : [:bars]}
|
161
|
-
model.supported_mtm_edit?('foos', nil).should
|
162
|
-
model.supported_mtm_edit?('bars', nil).should
|
163
|
-
model.supported_mtm_edit?('foos', true).should
|
164
|
-
model.supported_mtm_edit?('bars', true).should
|
161
|
+
model.supported_mtm_edit?('foos', nil).should == false
|
162
|
+
model.supported_mtm_edit?('bars', nil).should == true
|
163
|
+
model.supported_mtm_edit?('foos', true).should == true
|
164
|
+
model.supported_mtm_edit?('bars', true).should == false
|
165
165
|
model.mtm_associations ['bars']
|
166
|
-
model.supported_mtm_edit?('foos', nil).should
|
167
|
-
model.supported_mtm_edit?('bars', nil).should
|
166
|
+
model.supported_mtm_edit?('foos', nil).should == false
|
167
|
+
model.supported_mtm_edit?('bars', nil).should == true
|
168
168
|
model.mtm_associations{|req| req ? ['foos'] : ['bars']}
|
169
|
-
model.supported_mtm_edit?('foos', nil).should
|
170
|
-
model.supported_mtm_edit?('bars', nil).should
|
171
|
-
model.supported_mtm_edit?('foos', true).should
|
172
|
-
model.supported_mtm_edit?('bars', true).should
|
169
|
+
model.supported_mtm_edit?('foos', nil).should == false
|
170
|
+
model.supported_mtm_edit?('bars', nil).should == true
|
171
|
+
model.supported_mtm_edit?('foos', true).should == true
|
172
|
+
model.supported_mtm_edit?('bars', true).should == false
|
173
173
|
end
|
174
174
|
|
175
175
|
it "should handle inline_mtm_associations lookup" do
|
176
|
-
model.supported_mtm_update?('foos', nil).should
|
177
|
-
model.supported_mtm_update?('bars', nil).should
|
176
|
+
model.supported_mtm_update?('foos', nil).should == false
|
177
|
+
model.supported_mtm_update?('bars', nil).should == false
|
178
178
|
framework.inline_mtm_associations [:foos]
|
179
|
-
model.supported_mtm_update?('foos', nil).should
|
180
|
-
model.supported_mtm_update?('bars', nil).should
|
179
|
+
model.supported_mtm_update?('foos', nil).should == true
|
180
|
+
model.supported_mtm_update?('bars', nil).should == false
|
181
181
|
framework.inline_mtm_associations{|mod, req| req ? [:foos] : [:bars]}
|
182
|
-
model.supported_mtm_update?('foos', nil).should
|
183
|
-
model.supported_mtm_update?('bars', nil).should
|
184
|
-
model.supported_mtm_update?('foos', true).should
|
185
|
-
model.supported_mtm_update?('bars', true).should
|
182
|
+
model.supported_mtm_update?('foos', nil).should == false
|
183
|
+
model.supported_mtm_update?('bars', nil).should == true
|
184
|
+
model.supported_mtm_update?('foos', true).should == true
|
185
|
+
model.supported_mtm_update?('bars', true).should == false
|
186
186
|
model.inline_mtm_associations ['bars']
|
187
|
-
model.supported_mtm_update?('foos', nil).should
|
188
|
-
model.supported_mtm_update?('bars', nil).should
|
187
|
+
model.supported_mtm_update?('foos', nil).should == false
|
188
|
+
model.supported_mtm_update?('bars', nil).should == true
|
189
189
|
model.inline_mtm_associations{|req| req ? ['foos'] : ['bars']}
|
190
|
-
model.supported_mtm_update?('foos', nil).should
|
191
|
-
model.supported_mtm_update?('bars', nil).should
|
192
|
-
model.supported_mtm_update?('foos', true).should
|
193
|
-
model.supported_mtm_update?('bars', true).should
|
190
|
+
model.supported_mtm_update?('foos', nil).should == false
|
191
|
+
model.supported_mtm_update?('bars', nil).should == true
|
192
|
+
model.supported_mtm_update?('foos', true).should == true
|
193
|
+
model.supported_mtm_update?('bars', true).should == false
|
194
194
|
end
|
195
195
|
|
196
196
|
it "should handle association_links lookup" do
|
@@ -206,17 +206,17 @@ describe AutoForme do
|
|
206
206
|
end
|
207
207
|
|
208
208
|
it "should handle lazy_load_association_links lookup" do
|
209
|
-
model.lazy_load_association_links?(:show, nil).should
|
209
|
+
model.lazy_load_association_links?(:show, nil).should == false
|
210
210
|
framework.lazy_load_association_links true
|
211
|
-
model.lazy_load_association_links?(:show, nil).should
|
211
|
+
model.lazy_load_association_links?(:show, nil).should == true
|
212
212
|
framework.lazy_load_association_links{|mod, type, req| req > 2}
|
213
|
-
model.lazy_load_association_links?(:show, 1).should
|
214
|
-
model.lazy_load_association_links?(:show, 3).should
|
213
|
+
model.lazy_load_association_links?(:show, 1).should == false
|
214
|
+
model.lazy_load_association_links?(:show, 3).should == true
|
215
215
|
model.lazy_load_association_links false
|
216
|
-
model.lazy_load_association_links?(:show, nil).should
|
216
|
+
model.lazy_load_association_links?(:show, nil).should == false
|
217
217
|
model.lazy_load_association_links{|type, req| req > 2}
|
218
|
-
model.lazy_load_association_links?(:show, 1).should
|
219
|
-
model.lazy_load_association_links?(:show, 3).should
|
218
|
+
model.lazy_load_association_links?(:show, 1).should == false
|
219
|
+
model.lazy_load_association_links?(:show, 3).should == true
|
220
220
|
end
|
221
221
|
|
222
222
|
it "should handle form_attributes lookup" do
|
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: 0.5.
|
4
|
+
version: 0.5.4
|
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-01-
|
11
|
+
date: 2014-01-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: forme
|