Skip to content

Commit

Permalink
updates for rails 3.2.12 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
mattherick committed Mar 12, 2013
1 parent edbc365 commit 9568844
Show file tree
Hide file tree
Showing 16 changed files with 52 additions and 60 deletions.
4 changes: 1 addition & 3 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@

source :rubygems
gemspec

gemspec
49 changes: 26 additions & 23 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,36 +1,39 @@
PATH
remote: .
specs:
translate_columns (1.1.0)
activerecord (~> 3.0.0)
translate_columns (1.1.1)
activerecord (~> 3.2.12)

GEM
remote: http://rubygems.org/
specs:
activemodel (3.0.3)
activesupport (= 3.0.3)
builder (~> 2.1.2)
i18n (~> 0.4)
activerecord (3.0.3)
activemodel (= 3.0.3)
activesupport (= 3.0.3)
arel (~> 2.0.2)
tzinfo (~> 0.3.23)
activesupport (3.0.3)
arel (2.0.7)
builder (2.1.2)
i18n (0.5.0)
mocha (0.9.10)
rake
rake (0.8.7)
sqlite3 (1.3.3)
tzinfo (0.3.24)
activemodel (3.2.12)
activesupport (= 3.2.12)
builder (~> 3.0.0)
activerecord (3.2.12)
activemodel (= 3.2.12)
activesupport (= 3.2.12)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
activesupport (3.2.12)
i18n (~> 0.6)
multi_json (~> 1.0)
arel (3.0.2)
builder (3.0.4)
i18n (0.6.4)
metaclass (0.0.1)
mocha (0.13.3)
metaclass (~> 0.0.1)
multi_json (1.6.1)
rake (10.0.3)
sqlite3 (1.3.7)
tzinfo (0.3.37)

PLATFORMS
ruby

DEPENDENCIES
activerecord (~> 3.0.0)
mocha (~> 0.9.3)
sqlite3 (~> 1.3.3)
mocha (~> 0.13.3)
rake (~> 10.0.3)
sqlite3 (~> 1.3.7)
translate_columns!
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
require 'rdoc/task'

desc 'Default: run unit tests.'
task :default => :test
Expand All @@ -20,4 +20,4 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
rdoc.options << '--line-numbers' << '--inline-source'
rdoc.rdoc_files.include('README')
rdoc.rdoc_files.include('lib/**/*.rb')
end
end
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.1.1
1.1.1
4 changes: 1 addition & 3 deletions init.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@

require 'translate_columns'

require 'translate_columns'
2 changes: 1 addition & 1 deletion install.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# Install hook code here
# Install hook code here
4 changes: 2 additions & 2 deletions lib/translate_columns.rb
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def translation
if !@translation || (@translation.locale != translation_locale)
raise MissingParent, "Cannot create translations without a stored parent" if new_record?
# try to find translation or build a new one
@translation = translations.find_by_locale(translation_locale) || translations.build(:locale => translation_locale)
@translation = translations.where(:locale => translation_locale).first || translations.build(:locale => translation_locale)
end
@translation
else
Expand Down Expand Up @@ -225,4 +225,4 @@ def attributes_with_locale=(new_attributes, guard_protected_attributes = true)
end

end
end
end
7 changes: 3 additions & 4 deletions test/fixtures/document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ class Document < ActiveRecord::Base
has_many :translations, :class_name => 'DocumentTranslation'
translate_columns :title, :body

validates_presence_of :title
validates_length_of :title, :within => 3..200
validates :title, :presence => true, :length => { :in => 3..200 }
validates :body, :length => { :in => 3..500 }

validates_length_of :body, :within => 3..500
end
end
2 changes: 1 addition & 1 deletion test/fixtures/document_translation.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
class DocumentTranslation < ActiveRecord::Base

end
end
3 changes: 1 addition & 2 deletions test/fixtures/document_translations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ translation2:
document_id: 1
locale: fr
title: Un title en francais
body:

body:
3 changes: 1 addition & 2 deletions test/fixtures/documents.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ document2:
title: Test Document Number 2
locale: en
body: This is a second test document with some random content for the body.
published_at: "2009-09-23 21:53:46"

published_at: "2009-09-23 21:53:46"
3 changes: 1 addition & 2 deletions test/fixtures/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,4 @@
t.column "body", :text
t.timestamps
end
end

end
3 changes: 1 addition & 2 deletions test/lib/activerecord_connector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@
require 'active_record/fixtures'

conf = YAML::load(File.open(File.dirname(__FILE__) + '/../database.yml'))
ActiveRecord::Base.establish_connection(conf['sqlite3'])

ActiveRecord::Base.establish_connection(conf['sqlite3'])
4 changes: 1 addition & 3 deletions test/lib/activerecord_test_helper.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@

require 'activerecord_connector'
require File.join(File.dirname(__FILE__), '../fixtures/schema.rb')

module ActiverecordTestHelper
FIXTURES_PATH = File.join(File.dirname(__FILE__), '/../fixtures')
dep = defined?(ActiveSupport::Dependencies) ? ActiveSupport::Dependencies : ::Dependencies
dep.autoload_paths.unshift FIXTURES_PATH
end

end
8 changes: 4 additions & 4 deletions test/translate_columns_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require 'bundler/setup'
require 'test/unit'
require 'mocha'
require "mocha/setup"

require 'activerecord_test_helper'
require 'translate_columns'
Expand All @@ -12,11 +12,11 @@ class TranslateColumnsTest < Test::Unit::TestCase
include ActiverecordTestHelper

def setup
@docs = Fixtures.create_fixtures(FIXTURES_PATH, ['documents', 'document_translations'])
@docs = ActiveRecord::Fixtures.create_fixtures(FIXTURES_PATH, ['documents', 'document_translations'])
end

def teardown
Fixtures.reset_cache
ActiveRecord::Fixtures.reset_cache
end

def test_basic_document_fields
Expand Down Expand Up @@ -150,4 +150,4 @@ def test_create_new_document_with_specific_locale
assert doc.save
end

end
end
10 changes: 5 additions & 5 deletions translate_columns.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ Gem::Specification.new do |s|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.require_paths = ["lib"]

s.add_dependency("activerecord", "~> 3.0.0")
s.add_development_dependency(%q<mocha>, "~> 0.9.3")
s.add_development_dependency(%q<sqlite3>, "~> 1.3.3")
end

s.add_dependency("activerecord", "~> 3.2.12")
s.add_development_dependency("rake", "~> 10.0.3")
s.add_development_dependency("mocha", "~> 0.13.3")
s.add_development_dependency("sqlite3", "~> 1.3.7")
end

0 comments on commit 9568844

Please sign in to comment.