autoforme 0.5.3 → 0.5.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ec337a25a71c6c86396c93e659b5b0729d55a8a3
4
- data.tar.gz: 3c0e80ddbfc27c16befd3d99c984eb417f0734ad
3
+ metadata.gz: 7a6b8a4263970ea2e5bf3a985b8b4628af73c5f3
4
+ data.tar.gz: b5cc0a111748da7426f12d748e6a6a675395cbf7
5
5
  SHA512:
6
- metadata.gz: 9b6c976adf8f6a38e97efaec67e09fa174d189c15db3783e78c78d6f704741adf1ce69946fb921bf8bbe553c92c0f34d3ef958c7231eb8b6a737c3238fc55a03
7
- data.tar.gz: d5e3c5310a07a87b64c0f311884bdb83bf9e46212030fbb9504c2380b920b4663fe1032e6671e92e47a32a9f9f76b68e2a8ce2a0ded87058cf2d5542861c539e
6
+ metadata.gz: e8c36b982a6d2df2caafb06e3c9514cf2a69a9369ca2beb44fe9550c9774f4734ec84bbdc8d59d35557a9139909194f8019291c9dc1b0bc8f6e797799c23b876
7
+ data.tar.gz: 47abfeb25954620e28aaadd6cc9f90958326f2009db8495e2a25f8deb58af93a06d10ac6abc7b9d29267bca9d2a534d0cb8c1416076dee95895d3c0354dc466f
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ === 0.5.4 (2014-01-06)
2
+
3
+ * Qualify associated foreign key columns when searching, fixing issues when eager_graph is used on the model (jeremyevans)
4
+
1
5
  === 0.5.3 (2014-01-02)
2
6
 
3
7
  * Fix searching by associated object that uses autocompleting (jeremyevans)
@@ -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
@@ -1,6 +1,6 @@
1
1
  module AutoForme
2
2
  # Version constant, use <tt>AutoForme.version</tt> instead.
3
- VERSION = '0.5.3'.freeze
3
+ VERSION = '0.5.4'.freeze
4
4
 
5
5
  # Returns the version as a frozen string (e.g. '0.1.0')
6
6
  def self.version
@@ -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}]])
@@ -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}
@@ -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 be_true
136
- model.supported_action?(:edit, nil).should be_true
137
- model.supported_action?(:search, nil).should be_true
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 be_true
140
- model.supported_action?(:edit, nil).should be_false
141
- model.supported_action?(:search, nil).should be_true
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 be_false
144
- model.supported_action?(:new, true).should be_true
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 be_false
147
- model.supported_action?(:edit, nil).should be_true
148
- model.supported_action?(:search, nil).should be_true
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 be_false
151
- model.supported_action?(:new, true).should be_true
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 be_false
156
- model.supported_mtm_edit?('bars', nil).should be_false
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 be_true
159
- model.supported_mtm_edit?('bars', nil).should be_false
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 be_false
162
- model.supported_mtm_edit?('bars', nil).should be_true
163
- model.supported_mtm_edit?('foos', true).should be_true
164
- model.supported_mtm_edit?('bars', true).should be_false
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 be_false
167
- model.supported_mtm_edit?('bars', nil).should be_true
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 be_false
170
- model.supported_mtm_edit?('bars', nil).should be_true
171
- model.supported_mtm_edit?('foos', true).should be_true
172
- model.supported_mtm_edit?('bars', true).should be_false
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 be_false
177
- model.supported_mtm_update?('bars', nil).should be_false
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 be_true
180
- model.supported_mtm_update?('bars', nil).should be_false
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 be_false
183
- model.supported_mtm_update?('bars', nil).should be_true
184
- model.supported_mtm_update?('foos', true).should be_true
185
- model.supported_mtm_update?('bars', true).should be_false
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 be_false
188
- model.supported_mtm_update?('bars', nil).should be_true
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 be_false
191
- model.supported_mtm_update?('bars', nil).should be_true
192
- model.supported_mtm_update?('foos', true).should be_true
193
- model.supported_mtm_update?('bars', true).should be_false
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 be_false
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 be_true
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 be_false
214
- model.lazy_load_association_links?(:show, 3).should be_true
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 be_false
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 be_false
219
- model.lazy_load_association_links?(:show, 3).should be_true
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.3
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-02 00:00:00.000000000 Z
11
+ date: 2014-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: forme