Permalink
Browse files

Merge pull request #1 from lunks/master

Using ActiveModel instead of ActiveRecord
  • Loading branch information...
plentz committed Aug 31, 2011
2 parents ccc7dc1 + 264b7a0 commit fc0881eab1c00fe0c72ce6e3e3245b6f33b2b4da
Showing with 13 additions and 101 deletions.
  1. +1 −5 Gemfile
  2. +1 −43 Gemfile.lock
  3. +4 −2 app/models/foo.rb
  4. +0 −8 config/environments/development.rb
  5. +0 −21 config/environments/test.rb
  6. +4 −5 config/locales/en.yml
  7. +3 −2 spec/models/foo_spec.rb
  8. +0 −15 spec/spec_helper.rb
View
@@ -1,8 +1,4 @@
source 'http://rubygems.org'
-gem 'rails', '3.0.10'
+gem 'activemodel', '3.0.10'
gem 'rspec-rails'
-gem 'shoulda-matchers'
-
-gem 'sqlite3-ruby', :platforms => :ruby
-gem 'activerecord-jdbcsqlite3-adapter', :platforms => :jruby
View
@@ -2,9 +2,6 @@ GEM
remote: http://rubygems.org/
specs:
abstract (1.0.0)
- actionmailer (3.0.10)
- actionpack (= 3.0.10)
- mail (~> 2.2.19)
actionpack (3.0.10)
activemodel (= 3.0.10)
activesupport (= 3.0.10)
@@ -19,46 +16,17 @@ GEM
activesupport (= 3.0.10)
builder (~> 2.1.2)
i18n (~> 0.5.0)
- activerecord (3.0.10)
- activemodel (= 3.0.10)
- activesupport (= 3.0.10)
- arel (~> 2.0.10)
- tzinfo (~> 0.3.23)
- activerecord-jdbc-adapter (1.1.3)
- activerecord-jdbcsqlite3-adapter (1.1.3)
- activerecord-jdbc-adapter (= 1.1.3)
- jdbc-sqlite3 (~> 3.7.0)
- activeresource (3.0.10)
- activemodel (= 3.0.10)
- activesupport (= 3.0.10)
activesupport (3.0.10)
- arel (2.0.10)
builder (2.1.2)
diff-lcs (1.1.3)
erubis (2.6.6)
abstract (>= 1.0.0)
i18n (0.5.0)
- jdbc-sqlite3 (3.7.2)
- mail (2.2.19)
- activesupport (>= 2.3.6)
- i18n (>= 0.4.0)
- mime-types (~> 1.16)
- treetop (~> 1.4.8)
- mime-types (1.16)
- polyglot (0.3.2)
rack (1.2.3)
rack-mount (0.6.14)
rack (>= 1.0.0)
rack-test (0.5.7)
rack (>= 1.0)
- rails (3.0.10)
- actionmailer (= 3.0.10)
- actionpack (= 3.0.10)
- activerecord (= 3.0.10)
- activeresource (= 3.0.10)
- activesupport (= 3.0.10)
- bundler (~> 1.0)
- railties (= 3.0.10)
railties (3.0.10)
actionpack (= 3.0.10)
activesupport (= 3.0.10)
@@ -80,23 +48,13 @@ GEM
activesupport (~> 3.0)
railties (~> 3.0)
rspec (~> 2.6.0)
- shoulda-matchers (1.0.0.beta3)
- sqlite3 (1.3.4)
- sqlite3-ruby (1.3.3)
- sqlite3 (>= 1.3.3)
thor (0.14.6)
- treetop (1.4.10)
- polyglot
- polyglot (>= 0.3.1)
tzinfo (0.3.29)
PLATFORMS
java
ruby
DEPENDENCIES
- activerecord-jdbcsqlite3-adapter
- rails (= 3.0.10)
+ activemodel (= 3.0.10)
rspec-rails
- shoulda-matchers
- sqlite3-ruby
View
@@ -1,3 +1,5 @@
-class Foo < ActiveRecord::Base
- validates_presence_of :name
+class Foo
+ include ActiveModel::Validations
+ attr_accessor :name
+ validates_presence_of :name
end
@@ -9,15 +9,7 @@
# Log error messages when you accidentally call methods on nil.
config.whiny_nils = true
- # Show full error reports and disable caching
config.consider_all_requests_local = true
- config.action_view.debug_rjs = true
- config.action_controller.perform_caching = false
-
- # Don't care if the mailer can't send
- config.action_mailer.raise_delivery_errors = false
-
- # Print deprecation notices to the Rails logger
config.active_support.deprecation = :log
# Only use best-standards-support built into browsers
@@ -10,26 +10,5 @@
# Log error messages when you accidentally call methods on nil.
config.whiny_nils = true
- # Show full error reports and disable caching
- config.consider_all_requests_local = true
- config.action_controller.perform_caching = false
-
- # Raise exceptions instead of rendering exception templates
- config.action_dispatch.show_exceptions = false
-
- # Disable request forgery protection in test environment
- config.action_controller.allow_forgery_protection = false
-
- # Tell Action Mailer not to deliver emails to the real world.
- # The :test delivery method accumulates sent emails in the
- # ActionMailer::Base.deliveries array.
- config.action_mailer.delivery_method = :test
-
- # Use SQL instead of Active Record's schema dumper when creating the test database.
- # This is necessary if your schema can't be completely dumped by the schema dumper,
- # like if you have constraints or database-specific column types
- # config.active_record.schema_format = :sql
-
- # Print deprecation notices to the stderr
config.active_support.deprecation = :stderr
end
View
@@ -1,8 +1,7 @@
# encoding: UTF-8
en:
- activerecord:
- errors:
- messages:
- blank: "não pode ficar em branco"
- record_invalid: "A validação falhou: %{errors}"
+ errors:
+ messages:
+ blank: "não pode ficar em branco"
+ record_invalid: "A validação falhou: %{errors}"
View
@@ -5,9 +5,10 @@
describe Foo do
it "should do the right interpolation for error messages" do
foo = Foo.new
- lambda{foo.save!}.should raise_error ActiveRecord::RecordInvalid
+ foo.valid?
+ lambda{I18n.t("errors.messages.record_invalid", :errors => foo.errors.full_messages)}.should_not raise_error
end
-
+
it "should decode json even with special chars" do
ActiveSupport::JSON.decode({:message => "á"}.to_json)['message'].should eq "á"
end
View
@@ -8,20 +8,5 @@
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
RSpec.configure do |config|
- # == Mock Framework
- #
- # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
- #
- # config.mock_with :mocha
- # config.mock_with :flexmock
- # config.mock_with :rr
config.mock_with :rspec
-
- # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
- config.fixture_path = "#{::Rails.root}/spec/fixtures"
-
- # If you're not using ActiveRecord, or you'd prefer not to run each of your
- # examples within a transaction, remove the following line or assign false
- # instead of true.
- config.use_transactional_fixtures = true
end

0 comments on commit fc0881e

Please sign in to comment.