diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..46622f6 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,9 @@ +rvm: + - 1.9.3 + - 2.0.0 + +gemfile: + - gemfiles/3.0.gemfile + - gemfiles/3.1.gemfile + - gemfiles/3.2.gemfile + - gemfiles/4.0.gemfile diff --git a/Appraisals b/Appraisals new file mode 100644 index 0000000..70c6fe3 --- /dev/null +++ b/Appraisals @@ -0,0 +1,19 @@ +appraise "3.0" do + gem "activerecord", "~> 3.0.20" + gem "validates_existence", :path => "../" +end + +appraise "3.1" do + gem "activerecord", "~> 3.1.12" + gem "validates_existence", :path => "../" +end + +appraise "3.2" do + gem "activerecord", "~> 3.2.15" + gem "validates_existence", :path => "../" +end + +appraise "4.0" do + gem "activerecord", "~> 4.0.0" + gem "validates_existence", :path => "../" +end diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..f68a903 --- /dev/null +++ b/Gemfile @@ -0,0 +1,4 @@ +source "https://rubygems.org" + +gemspec + diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..636bdbd --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,90 @@ +PATH + remote: . + specs: + validates_existence (0.9.1) + activerecord (>= 3.0.0) + jeweler + validates_existence + +GEM + remote: https://rubygems.org/ + specs: + activemodel (4.0.0) + activesupport (= 4.0.0) + builder (~> 3.1.0) + activerecord (4.0.0) + activemodel (= 4.0.0) + activerecord-deprecated_finders (~> 1.0.2) + activesupport (= 4.0.0) + arel (~> 4.0.0) + activerecord-deprecated_finders (1.0.3) + activesupport (4.0.0) + i18n (~> 0.6, >= 0.6.4) + minitest (~> 4.2) + multi_json (~> 1.3) + thread_safe (~> 0.1) + tzinfo (~> 0.3.37) + addressable (2.3.5) + appraisal (1.0.0.beta1) + bundler + rake + thor (~> 0.18.1) + arel (4.0.1) + atomic (1.1.14) + builder (3.1.4) + faraday (0.8.8) + multipart-post (~> 1.2.0) + git (1.2.6) + github_api (0.10.1) + addressable + faraday (~> 0.8.1) + hashie (>= 1.2) + multi_json (~> 1.4) + nokogiri (~> 1.5.2) + oauth2 + hashie (2.0.5) + highline (1.6.20) + httpauth (0.2.0) + i18n (0.6.5) + jeweler (1.8.8) + builder + bundler (~> 1.0) + git (>= 1.2.5) + github_api (= 0.10.1) + highline (>= 1.6.15) + nokogiri (= 1.5.10) + rake + rdoc + json (1.8.1) + jwt (0.1.8) + multi_json (>= 1.5) + minitest (4.7.5) + multi_json (1.8.2) + multi_xml (0.5.5) + multipart-post (1.2.0) + nokogiri (1.5.10) + oauth2 (0.9.2) + faraday (~> 0.8) + httpauth (~> 0.2) + jwt (~> 0.1.4) + multi_json (~> 1.0) + multi_xml (~> 0.5) + rack (~> 1.2) + rack (1.5.2) + rake (10.1.0) + rdoc (4.0.1) + json (~> 1.4) + sqlite3 (1.3.7) + thor (0.18.1) + thread_safe (0.1.3) + atomic + tzinfo (0.3.38) + +PLATFORMS + ruby + +DEPENDENCIES + appraisal (>= 1.0.0.beta) + minitest (~> 4.0) + sqlite3 + validates_existence! diff --git a/Rakefile b/Rakefile index ded994a..5928010 100644 --- a/Rakefile +++ b/Rakefile @@ -1,3 +1,4 @@ +require "rubygems" require "rake" require "rake/testtask" require "rake/clean" @@ -17,22 +18,18 @@ begin jewel.description = "A library for validating model association existence." jewel.authors = ["Tanel Suurhans", "Tarmo Lehtpuu"] jewel.files = FileList["rails/*.rb", "lib/**/*.rb", "*.rb", "MIT-LICENCE", "README.markdown"] - jewel.add_dependency "active_record" + jewel.add_dependency "activerecord", ">= 3.0.0" + jewel.add_development_dependency "appraisal", ">= 1.0.0.beta" + jewel.add_development_dependency "minitest", "~> 4.0" + jewel.add_development_dependency "sqlite3" end rescue LoadError puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com" end -Rake::TestTask.new(:test_rails3) do |t| +Rake::TestTask.new(:test) do |t| t.libs << "lib" - t.libs << "test/rails3" - t.pattern = "test/rails3/**/*_test.rb" - t.verbose = true -end - -Rake::TestTask.new(:test_rails31) do |t| - t.libs << "lib" - t.libs << "test/rails31" - t.pattern = "test/rails31/**/*_test.rb" + t.libs << "test" + t.pattern = "test/**/*_test.rb" t.verbose = true end diff --git a/gemfiles/3.0.gemfile b/gemfiles/3.0.gemfile new file mode 100644 index 0000000..8bffd7e --- /dev/null +++ b/gemfiles/3.0.gemfile @@ -0,0 +1,8 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "activerecord", "~> 3.0.20" +gem "validates_existence", :path=>"../" + +gemspec :path=>".././" diff --git a/gemfiles/3.0.gemfile.lock b/gemfiles/3.0.gemfile.lock new file mode 100644 index 0000000..7e3897f --- /dev/null +++ b/gemfiles/3.0.gemfile.lock @@ -0,0 +1,83 @@ +PATH + remote: .. + specs: + validates_existence (0.9.1) + activerecord (>= 3.0.0) + jeweler + validates_existence + +GEM + remote: https://rubygems.org/ + specs: + activemodel (3.0.20) + activesupport (= 3.0.20) + builder (~> 2.1.2) + i18n (~> 0.5.0) + activerecord (3.0.20) + activemodel (= 3.0.20) + activesupport (= 3.0.20) + arel (~> 2.0.10) + tzinfo (~> 0.3.23) + activesupport (3.0.20) + addressable (2.3.5) + appraisal (1.0.0.beta1) + bundler + rake + thor (~> 0.18.1) + arel (2.0.10) + builder (2.1.2) + faraday (0.8.8) + multipart-post (~> 1.2.0) + git (1.2.6) + github_api (0.10.1) + addressable + faraday (~> 0.8.1) + hashie (>= 1.2) + multi_json (~> 1.4) + nokogiri (~> 1.5.2) + oauth2 + hashie (2.0.5) + highline (1.6.20) + httpauth (0.2.0) + i18n (0.5.0) + jeweler (1.8.8) + builder + bundler (~> 1.0) + git (>= 1.2.5) + github_api (= 0.10.1) + highline (>= 1.6.15) + nokogiri (= 1.5.10) + rake + rdoc + json (1.8.1) + jwt (0.1.8) + multi_json (>= 1.5) + minitest (4.7.5) + multi_json (1.8.2) + multi_xml (0.5.5) + multipart-post (1.2.0) + nokogiri (1.5.10) + oauth2 (0.9.2) + faraday (~> 0.8) + httpauth (~> 0.2) + jwt (~> 0.1.4) + multi_json (~> 1.0) + multi_xml (~> 0.5) + rack (~> 1.2) + rack (1.5.2) + rake (10.1.0) + rdoc (4.0.1) + json (~> 1.4) + sqlite3 (1.3.7) + thor (0.18.1) + tzinfo (0.3.38) + +PLATFORMS + ruby + +DEPENDENCIES + activerecord (~> 3.0.20) + appraisal (>= 1.0.0.beta) + minitest (~> 4.0) + sqlite3 + validates_existence! diff --git a/gemfiles/3.1.gemfile b/gemfiles/3.1.gemfile new file mode 100644 index 0000000..6d36569 --- /dev/null +++ b/gemfiles/3.1.gemfile @@ -0,0 +1,8 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "activerecord", "~> 3.1.12" +gem "validates_existence", :path=>"../" + +gemspec :path=>".././" diff --git a/gemfiles/3.1.gemfile.lock b/gemfiles/3.1.gemfile.lock new file mode 100644 index 0000000..9a8b16f --- /dev/null +++ b/gemfiles/3.1.gemfile.lock @@ -0,0 +1,84 @@ +PATH + remote: .. + specs: + validates_existence (0.9.1) + activerecord (>= 3.0.0) + jeweler + validates_existence + +GEM + remote: https://rubygems.org/ + specs: + activemodel (3.1.12) + activesupport (= 3.1.12) + builder (~> 3.0.0) + i18n (~> 0.6) + activerecord (3.1.12) + activemodel (= 3.1.12) + activesupport (= 3.1.12) + arel (~> 2.2.3) + tzinfo (~> 0.3.29) + activesupport (3.1.12) + multi_json (~> 1.0) + addressable (2.3.5) + appraisal (1.0.0.beta1) + bundler + rake + thor (~> 0.18.1) + arel (2.2.3) + builder (3.0.4) + faraday (0.8.8) + multipart-post (~> 1.2.0) + git (1.2.6) + github_api (0.10.1) + addressable + faraday (~> 0.8.1) + hashie (>= 1.2) + multi_json (~> 1.4) + nokogiri (~> 1.5.2) + oauth2 + hashie (2.0.5) + highline (1.6.20) + httpauth (0.2.0) + i18n (0.6.5) + jeweler (1.8.8) + builder + bundler (~> 1.0) + git (>= 1.2.5) + github_api (= 0.10.1) + highline (>= 1.6.15) + nokogiri (= 1.5.10) + rake + rdoc + json (1.8.1) + jwt (0.1.8) + multi_json (>= 1.5) + minitest (4.7.5) + multi_json (1.8.2) + multi_xml (0.5.5) + multipart-post (1.2.0) + nokogiri (1.5.10) + oauth2 (0.9.2) + faraday (~> 0.8) + httpauth (~> 0.2) + jwt (~> 0.1.4) + multi_json (~> 1.0) + multi_xml (~> 0.5) + rack (~> 1.2) + rack (1.5.2) + rake (10.1.0) + rdoc (4.0.1) + json (~> 1.4) + sqlite3 (1.3.7) + thor (0.18.1) + tzinfo (0.3.38) + +PLATFORMS + ruby + +DEPENDENCIES + activerecord (~> 3.1.12) + appraisal (>= 1.0.0.beta) + minitest (~> 4.0) + sqlite3 + validates_existence! diff --git a/gemfiles/3.2.gemfile b/gemfiles/3.2.gemfile new file mode 100644 index 0000000..fbf20ee --- /dev/null +++ b/gemfiles/3.2.gemfile @@ -0,0 +1,8 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "activerecord", "~> 3.2.15" +gem "validates_existence", :path=>"../" + +gemspec :path=>".././" diff --git a/gemfiles/3.2.gemfile.lock b/gemfiles/3.2.gemfile.lock new file mode 100644 index 0000000..a49367c --- /dev/null +++ b/gemfiles/3.2.gemfile.lock @@ -0,0 +1,84 @@ +PATH + remote: .. + specs: + validates_existence (0.9.1) + activerecord (>= 3.0.0) + jeweler + validates_existence + +GEM + remote: https://rubygems.org/ + specs: + activemodel (3.2.15) + activesupport (= 3.2.15) + builder (~> 3.0.0) + activerecord (3.2.15) + activemodel (= 3.2.15) + activesupport (= 3.2.15) + arel (~> 3.0.2) + tzinfo (~> 0.3.29) + activesupport (3.2.15) + i18n (~> 0.6, >= 0.6.4) + multi_json (~> 1.0) + addressable (2.3.5) + appraisal (1.0.0.beta1) + bundler + rake + thor (~> 0.18.1) + arel (3.0.2) + builder (3.0.4) + faraday (0.8.8) + multipart-post (~> 1.2.0) + git (1.2.6) + github_api (0.10.1) + addressable + faraday (~> 0.8.1) + hashie (>= 1.2) + multi_json (~> 1.4) + nokogiri (~> 1.5.2) + oauth2 + hashie (2.0.5) + highline (1.6.20) + httpauth (0.2.0) + i18n (0.6.5) + jeweler (1.8.8) + builder + bundler (~> 1.0) + git (>= 1.2.5) + github_api (= 0.10.1) + highline (>= 1.6.15) + nokogiri (= 1.5.10) + rake + rdoc + json (1.8.1) + jwt (0.1.8) + multi_json (>= 1.5) + minitest (4.7.5) + multi_json (1.8.2) + multi_xml (0.5.5) + multipart-post (1.2.0) + nokogiri (1.5.10) + oauth2 (0.9.2) + faraday (~> 0.8) + httpauth (~> 0.2) + jwt (~> 0.1.4) + multi_json (~> 1.0) + multi_xml (~> 0.5) + rack (~> 1.2) + rack (1.5.2) + rake (10.1.0) + rdoc (4.0.1) + json (~> 1.4) + sqlite3 (1.3.7) + thor (0.18.1) + tzinfo (0.3.38) + +PLATFORMS + ruby + +DEPENDENCIES + activerecord (~> 3.2.15) + appraisal (>= 1.0.0.beta) + minitest (~> 4.0) + sqlite3 + validates_existence! diff --git a/gemfiles/4.0.gemfile b/gemfiles/4.0.gemfile new file mode 100644 index 0000000..dd6b3c2 --- /dev/null +++ b/gemfiles/4.0.gemfile @@ -0,0 +1,8 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "activerecord", "~> 4.0.0" +gem "validates_existence", :path=>"../" + +gemspec :path=>".././" diff --git a/gemfiles/4.0.gemfile.lock b/gemfiles/4.0.gemfile.lock new file mode 100644 index 0000000..0b558bb --- /dev/null +++ b/gemfiles/4.0.gemfile.lock @@ -0,0 +1,91 @@ +PATH + remote: .. + specs: + validates_existence (0.9.1) + activerecord (>= 3.0.0) + jeweler + validates_existence + +GEM + remote: https://rubygems.org/ + specs: + activemodel (4.0.0) + activesupport (= 4.0.0) + builder (~> 3.1.0) + activerecord (4.0.0) + activemodel (= 4.0.0) + activerecord-deprecated_finders (~> 1.0.2) + activesupport (= 4.0.0) + arel (~> 4.0.0) + activerecord-deprecated_finders (1.0.3) + activesupport (4.0.0) + i18n (~> 0.6, >= 0.6.4) + minitest (~> 4.2) + multi_json (~> 1.3) + thread_safe (~> 0.1) + tzinfo (~> 0.3.37) + addressable (2.3.5) + appraisal (1.0.0.beta1) + bundler + rake + thor (~> 0.18.1) + arel (4.0.1) + atomic (1.1.14) + builder (3.1.4) + faraday (0.8.8) + multipart-post (~> 1.2.0) + git (1.2.6) + github_api (0.10.1) + addressable + faraday (~> 0.8.1) + hashie (>= 1.2) + multi_json (~> 1.4) + nokogiri (~> 1.5.2) + oauth2 + hashie (2.0.5) + highline (1.6.20) + httpauth (0.2.0) + i18n (0.6.5) + jeweler (1.8.8) + builder + bundler (~> 1.0) + git (>= 1.2.5) + github_api (= 0.10.1) + highline (>= 1.6.15) + nokogiri (= 1.5.10) + rake + rdoc + json (1.8.1) + jwt (0.1.8) + multi_json (>= 1.5) + minitest (4.7.5) + multi_json (1.8.2) + multi_xml (0.5.5) + multipart-post (1.2.0) + nokogiri (1.5.10) + oauth2 (0.9.2) + faraday (~> 0.8) + httpauth (~> 0.2) + jwt (~> 0.1.4) + multi_json (~> 1.0) + multi_xml (~> 0.5) + rack (~> 1.2) + rack (1.5.2) + rake (10.1.0) + rdoc (4.0.1) + json (~> 1.4) + sqlite3 (1.3.7) + thor (0.18.1) + thread_safe (0.1.3) + atomic + tzinfo (0.3.38) + +PLATFORMS + ruby + +DEPENDENCIES + activerecord (~> 4.0.0) + appraisal (>= 1.0.0.beta) + minitest (~> 4.0) + sqlite3 + validates_existence! diff --git a/test/shared/locales/pt.yml b/test/locales/pt.yml similarity index 100% rename from test/shared/locales/pt.yml rename to test/locales/pt.yml diff --git a/test/rails3/models/name.rb b/test/models/name.rb similarity index 100% rename from test/rails3/models/name.rb rename to test/models/name.rb diff --git a/test/rails3/models/user.rb b/test/models/user.rb similarity index 100% rename from test/rails3/models/user.rb rename to test/models/user.rb diff --git a/test/rails3/models/user_with_allow_new.rb b/test/models/user_with_allow_new.rb similarity index 100% rename from test/rails3/models/user_with_allow_new.rb rename to test/models/user_with_allow_new.rb diff --git a/test/rails3/models/user_with_allow_nil.rb b/test/models/user_with_allow_nil.rb similarity index 100% rename from test/rails3/models/user_with_allow_nil.rb rename to test/models/user_with_allow_nil.rb diff --git a/test/rails3/models/user_with_both.rb b/test/models/user_with_both.rb similarity index 100% rename from test/rails3/models/user_with_both.rb rename to test/models/user_with_both.rb diff --git a/test/rails3/models/user_with_fk.rb b/test/models/user_with_fk.rb similarity index 100% rename from test/rails3/models/user_with_fk.rb rename to test/models/user_with_fk.rb diff --git a/test/rails3/models/user_with_has_many.rb b/test/models/user_with_has_many.rb similarity index 100% rename from test/rails3/models/user_with_has_many.rb rename to test/models/user_with_has_many.rb diff --git a/test/rails3/models/user_with_old_syntax.rb b/test/models/user_with_old_syntax.rb similarity index 100% rename from test/rails3/models/user_with_old_syntax.rb rename to test/models/user_with_old_syntax.rb diff --git a/test/rails3/models/user_with_poly.rb b/test/models/user_with_poly.rb similarity index 100% rename from test/rails3/models/user_with_poly.rb rename to test/models/user_with_poly.rb diff --git a/test/rails3/models/user_with_poly_allow_nil.rb b/test/models/user_with_poly_allow_nil.rb similarity index 100% rename from test/rails3/models/user_with_poly_allow_nil.rb rename to test/models/user_with_poly_allow_nil.rb diff --git a/test/rails3/validates_existence_test.rb b/test/rails3/validates_existence_test.rb deleted file mode 100644 index beb3229..0000000 --- a/test/rails3/validates_existence_test.rb +++ /dev/null @@ -1,125 +0,0 @@ -require 'test_helper.rb' - -class TestValidatesExistence < Test::Unit::TestCase - - def setup - ActiveRecord::Schema.define(:version => 1) do - - create_table :names, :force => true do |t| - t.column :name, :string - end - - create_table :users, :force => true do |t| - t.references :name - t.references :relation, :polymorphic => true - end - - create_table :users2, :force => true do |t| - t.column :custom_id, :integer - end - - end - end - - def teardown - ActiveRecord::Base.connection.drop_table(:users) - ActiveRecord::Base.connection.drop_table(:names) - end - - def test_save_with_no_relation - user = User.new - assert_equal user.save, false - assert_not_nil user.errors[:name] - assert_not_nil user.errors[:name_id] - end - - def test_save_with_relation - name = Name.create(:name => "foo") - assert_equal User.new(:name => name).save, true - end - - def test_save_with_bogus_id - assert_equal User.new(:name_id => 100).save, false - end - - def test_allow_nil - assert_equal UserWithAllowNil.new.save, true - end - - def test_poly_relation - assert_equal UserWithPoly.new.save, false - end - - def test_poly_relation_with_name - name = Name.create(:name => "bar") - assert_equal UserWithPoly.new(:relation => name).save, true - end - - def test_poly_relation_with_allow_nil - assert_equal UserWithPolyAllowNil.new.save, true - end - - def test_argument_error - assert_raise ArgumentError do - UserWithHasMany.new.save - end - end - - def test_errors_on_one_field - user = UserWithBoth.new - user.save - - assert_not_nil user.errors[:name] - assert_empty user.errors[:name_id] - end - - def test_save_with_new_record - name = Name.create(:name => "foobar") - user = User.create(:name => name) - - user.name = Name.new - user.save - - assert_not_nil user.errors[:name] - end - - def test_save_with_new_record_and_allow_new - name = Name.new(:name => "foo") - assert_equal UserWithAllowNew.new(:name => name).save, true - end - - def test_save_with_custom_fk - user = UserWithFk.new - user.save - - assert_not_nil user.errors[:name] - assert_not_nil user.errors[:custom_id] - end - - def test_message_without_i18n - I18n.locale = :en - - user = User.new :name_id => 100 - user.save - - assert_equal ["does not exist"], user.errors[:name] - end - - def test_message_with_i18n - I18n.load_path << File.expand_path("./test/shared/locales/pt.yml") - I18n.backend.send(:init_translations) - I18n.locale = :pt - - user = User.new :name_id => 100 - user.save - - assert_equal %w(inexistente), user.errors[:name] - end - - def test_old_syntax - name = Name.create(:name => "foo") - assert_equal UserWithOldSyntax.new(:name => name).save, true - end - -end - diff --git a/test/rails31/models/name.rb b/test/rails31/models/name.rb deleted file mode 100644 index 452bb03..0000000 --- a/test/rails31/models/name.rb +++ /dev/null @@ -1,3 +0,0 @@ -class Name < ActiveRecord::Base - -end \ No newline at end of file diff --git a/test/rails31/models/user.rb b/test/rails31/models/user.rb deleted file mode 100644 index 7eac033..0000000 --- a/test/rails31/models/user.rb +++ /dev/null @@ -1,7 +0,0 @@ -class User < ActiveRecord::Base - - belongs_to :name - - validates :name, :existence => true - -end diff --git a/test/rails31/models/user_with_allow_new.rb b/test/rails31/models/user_with_allow_new.rb deleted file mode 100644 index 3669944..0000000 --- a/test/rails31/models/user_with_allow_new.rb +++ /dev/null @@ -1,9 +0,0 @@ -class UserWithAllowNew < ActiveRecord::Base - - self.table_name = "users" - - belongs_to :name - - validates :name, :existence => { :allow_new => true } - -end diff --git a/test/rails31/models/user_with_allow_nil.rb b/test/rails31/models/user_with_allow_nil.rb deleted file mode 100644 index 638ae32..0000000 --- a/test/rails31/models/user_with_allow_nil.rb +++ /dev/null @@ -1,9 +0,0 @@ -class UserWithAllowNil < ActiveRecord::Base - - self.table_name = "users" - - belongs_to :name - - validates :name, :existence => true, :allow_nil => true - -end \ No newline at end of file diff --git a/test/rails31/models/user_with_both.rb b/test/rails31/models/user_with_both.rb deleted file mode 100644 index 205c956..0000000 --- a/test/rails31/models/user_with_both.rb +++ /dev/null @@ -1,7 +0,0 @@ -class UserWithBoth < ActiveRecord::Base - self.table_name = "users" - - belongs_to :name - - validates :name, :existence => {:both => false} -end \ No newline at end of file diff --git a/test/rails31/models/user_with_fk.rb b/test/rails31/models/user_with_fk.rb deleted file mode 100644 index 4b1756e..0000000 --- a/test/rails31/models/user_with_fk.rb +++ /dev/null @@ -1,9 +0,0 @@ -class UserWithFk < ActiveRecord::Base - - self.table_name = "users2" - - belongs_to :name, :foreign_key => :custom_id - - validates :name, :existence => true - -end \ No newline at end of file diff --git a/test/rails31/models/user_with_has_many.rb b/test/rails31/models/user_with_has_many.rb deleted file mode 100644 index bf99703..0000000 --- a/test/rails31/models/user_with_has_many.rb +++ /dev/null @@ -1,7 +0,0 @@ -class UserWithHasMany < ActiveRecord::Base - self.table_name = "users" - - has_many :names - - validates :names, :existence => true -end \ No newline at end of file diff --git a/test/rails31/models/user_with_old_syntax.rb b/test/rails31/models/user_with_old_syntax.rb deleted file mode 100644 index 25520da..0000000 --- a/test/rails31/models/user_with_old_syntax.rb +++ /dev/null @@ -1,9 +0,0 @@ -class UserWithOldSyntax < ActiveRecord::Base - - self.table_name = "users" - - belongs_to :name - - validates_existence_of :name - -end diff --git a/test/rails31/models/user_with_poly.rb b/test/rails31/models/user_with_poly.rb deleted file mode 100644 index 13ed318..0000000 --- a/test/rails31/models/user_with_poly.rb +++ /dev/null @@ -1,9 +0,0 @@ -class UserWithPoly < ActiveRecord::Base - - self.table_name = "users" - - belongs_to :relation, :polymorphic => true - - validates :relation, :existence => true - -end diff --git a/test/rails31/models/user_with_poly_allow_nil.rb b/test/rails31/models/user_with_poly_allow_nil.rb deleted file mode 100644 index 03879d4..0000000 --- a/test/rails31/models/user_with_poly_allow_nil.rb +++ /dev/null @@ -1,9 +0,0 @@ -class UserWithPolyAllowNil < ActiveRecord::Base - - self.table_name = "users" - - belongs_to :relation, :polymorphic => true - - validates :relation, :existence => true, :allow_nil => true - -end \ No newline at end of file diff --git a/test/rails31/test_helper.rb b/test/rails31/test_helper.rb deleted file mode 100644 index 4f28527..0000000 --- a/test/rails31/test_helper.rb +++ /dev/null @@ -1,28 +0,0 @@ -require "rubygems" - -gem "rails", ">= 3.1.0" - -require "rails" -require "sqlite3" -require "test/unit" -require "active_record" -require "active_record/base" - -ActiveRecord::Migration.verbose = false -ActiveRecord::Base.establish_connection( - "adapter" => "sqlite3", - "database" => ":memory:" -) - -require File.join(File.dirname(__FILE__), "..", "..", "lib", "validates_existence") - -autoload :Name, File.join(File.dirname(__FILE__), "models", "name.rb") -autoload :User, File.join(File.dirname(__FILE__), "models", "user.rb") -autoload :UserWithOldSyntax, File.join(File.dirname(__FILE__), "models", "user_with_old_syntax.rb") -autoload :UserWithAllowNil, File.join(File.dirname(__FILE__), "models", "user_with_allow_nil.rb") -autoload :UserWithAllowNew, File.join(File.dirname(__FILE__), "models", "user_with_allow_new.rb") -autoload :UserWithPoly, File.join(File.dirname(__FILE__), "models", "user_with_poly.rb") -autoload :UserWithPolyAllowNil, File.join(File.dirname(__FILE__), "models", "user_with_poly_allow_nil.rb") -autoload :UserWithHasMany, File.join(File.dirname(__FILE__), "models", "user_with_has_many.rb") -autoload :UserWithBoth, File.join(File.dirname(__FILE__), "models", "user_with_both.rb") -autoload :UserWithFk, File.join(File.dirname(__FILE__), "models", "user_with_fk.rb") diff --git a/test/rails3/test_helper.rb b/test/test_helper.rb similarity index 90% rename from test/rails3/test_helper.rb rename to test/test_helper.rb index dfeed45..87eae1d 100644 --- a/test/rails3/test_helper.rb +++ b/test/test_helper.rb @@ -1,8 +1,4 @@ require "rubygems" - -gem "rails", "~> 3.0.7" - -require "rails" require "sqlite3" require "test/unit" require "active_record" @@ -14,7 +10,7 @@ "database" => ":memory:" ) -require File.join(File.dirname(__FILE__), "..", "..", "lib", "validates_existence") +require File.join(File.dirname(__FILE__), "..", "lib", "validates_existence") autoload :Name, File.join(File.dirname(__FILE__), "models", "name.rb") autoload :User, File.join(File.dirname(__FILE__), "models", "user.rb") diff --git a/test/rails31/validates_existence_test.rb b/test/validates_existence_test.rb similarity index 96% rename from test/rails31/validates_existence_test.rb rename to test/validates_existence_test.rb index 60fb6e3..90aba8c 100644 --- a/test/rails31/validates_existence_test.rb +++ b/test/validates_existence_test.rb @@ -1,4 +1,4 @@ -require 'test_helper.rb' +require 'test_helper' class TestValidatesExistence < Test::Unit::TestCase @@ -110,7 +110,7 @@ def test_message_without_i18n end def test_message_with_i18n - I18n.load_path << File.expand_path("./test/shared/locales/pt.yml") + I18n.load_path << File.expand_path("./test/locales/pt.yml") I18n.backend.send(:init_translations) I18n.locale = :pt diff --git a/validates_existence.gemspec b/validates_existence.gemspec index 9cf23a5..68675b8 100644 --- a/validates_existence.gemspec +++ b/validates_existence.gemspec @@ -9,7 +9,7 @@ Gem::Specification.new do |s| s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Tanel Suurhans", "Tarmo Lehtpuu"] - s.date = "2013-09-05" + s.date = "2013-11-01" s.description = "A library for validating model association existence." s.email = ["tanel.suurhans@perfectline.ee", "tarmo.lehtpuu@perfectline.ee"] s.extra_rdoc_files = [ @@ -23,14 +23,46 @@ Gem::Specification.new do |s| ] s.homepage = "http://github.com/perfectline/validates_existence/tree/master" s.require_paths = ["lib"] - s.rubygems_version = "2.0.3" + s.rubygems_version = "2.0.6" s.summary = "Validates Rails model belongs_to association existence." if s.respond_to? :specification_version then s.specification_version = 4 - s.add_runtime_dependency(%q, [">= 0"]) + + if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then + s.add_runtime_dependency(%q, [">= 0"]) + s.add_runtime_dependency(%q, [">= 0"]) + s.add_development_dependency(%q, [">= 1.0.0.beta"]) + s.add_development_dependency(%q, [">= 1.0.0.beta"]) + s.add_development_dependency(%q, [">= 1.0.0.beta"]) + s.add_development_dependency(%q, ["~> 4.0"]) + s.add_runtime_dependency(%q, [">= 3.0.0"]) + s.add_development_dependency(%q, [">= 1.0.0.beta"]) + s.add_development_dependency(%q, ["~> 4.0"]) + s.add_development_dependency(%q, [">= 0"]) + else + s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, [">= 1.0.0.beta"]) + s.add_dependency(%q, [">= 1.0.0.beta"]) + s.add_dependency(%q, [">= 1.0.0.beta"]) + s.add_dependency(%q, ["~> 4.0"]) + s.add_dependency(%q, [">= 3.0.0"]) + s.add_dependency(%q, [">= 1.0.0.beta"]) + s.add_dependency(%q, ["~> 4.0"]) + s.add_dependency(%q, [">= 0"]) + end else - s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, [">= 1.0.0.beta"]) + s.add_dependency(%q, [">= 1.0.0.beta"]) + s.add_dependency(%q, [">= 1.0.0.beta"]) + s.add_dependency(%q, ["~> 4.0"]) + s.add_dependency(%q, [">= 3.0.0"]) + s.add_dependency(%q, [">= 1.0.0.beta"]) + s.add_dependency(%q, ["~> 4.0"]) + s.add_dependency(%q, [">= 0"]) end end