From 0585087723baa0ae25516bec4195c2c311c80d3e Mon Sep 17 00:00:00 2001 From: Francis Chong Date: Tue, 20 Mar 2012 20:34:16 +0800 Subject: [PATCH] use active_model to avoid using active_record namespaces --- README.rdoc | 8 ++++---- lib/{active_record => active_model}/transitions.rb | 2 +- test/helper.rb | 2 +- test/test_active_record.rb | 6 +++--- test/test_active_record_timestamps.rb | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) rename lib/{active_record => active_model}/transitions.rb (99%) diff --git a/README.rdoc b/README.rdoc index 1f04036..7d913c7 100644 --- a/README.rdoc +++ b/README.rdoc @@ -12,11 +12,11 @@ This goes into your Gemfile: - gem "transitions", :require => ["transitions", "active_record/transitions"] + gem "transitions", :require => ["transitions", "active_model/transitions"] -… and this into your AR model: +… and this into your ORM model: - include ActiveRecord::Transitions + include ActiveModel::Transitions == Standalone @@ -62,7 +62,7 @@ bang(!)-version will call write_state. Given a model like this: class Order < ActiveRecord::Base - include ActiveRecord::Transitions + include ActiveModel::Transitions state_machine :auto_scopes => true do state :pick_line_items state :picking_line_items diff --git a/lib/active_record/transitions.rb b/lib/active_model/transitions.rb similarity index 99% rename from lib/active_record/transitions.rb rename to lib/active_model/transitions.rb index 2d0f993..7925491 100644 --- a/lib/active_record/transitions.rb +++ b/lib/active_model/transitions.rb @@ -20,7 +20,7 @@ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -module ActiveRecord +module ActiveModel module Transitions extend ActiveSupport::Concern diff --git a/test/helper.rb b/test/helper.rb index b84a2d3..389d1e3 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -9,7 +9,7 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib")) $LOAD_PATH.unshift(File.dirname(__FILE__)) require "transitions" -require "active_record/transitions" +require "active_model/transitions" class Test::Unit::TestCase diff --git a/test/test_active_record.rb b/test/test_active_record.rb index 3d3d823..6149c56 100644 --- a/test/test_active_record.rb +++ b/test/test_active_record.rb @@ -33,7 +33,7 @@ def self.up CreateLights.migrate(:up) class TrafficLight < ActiveRecord::Base - include ActiveRecord::Transitions + include ActiveModel::Transitions state_machine :auto_scopes => true do state :off @@ -73,7 +73,7 @@ class ConditionalValidatingTrafficLight < TrafficLight end class LightBulb < ActiveRecord::Base - include ActiveRecord::Transitions + include ActiveModel::Transitions state_machine do state :off @@ -203,7 +203,7 @@ class TestScopes < Test::Unit::TestCase test 'scope generation raises an exception if we try to overwrite an existing method' do assert_raise(Transitions::InvalidMethodOverride) { class Light < ActiveRecord::Base - include ActiveRecord::Transitions + include ActiveModel::Transitions state_machine :auto_scopes => true do state :new diff --git a/test/test_active_record_timestamps.rb b/test/test_active_record_timestamps.rb index 727c9f6..947fc95 100644 --- a/test/test_active_record_timestamps.rb +++ b/test/test_active_record_timestamps.rb @@ -4,7 +4,7 @@ create_database class Order < ActiveRecord::Base - include ActiveRecord::Transitions + include ActiveModel::Transitions state_machine do state :opened @@ -104,7 +104,7 @@ def create_order(state = nil) test "passing an invalid value to timestamp options should raise an exception" do assert_raise(ArgumentError) do class Order < ActiveRecord::Base - include ActiveRecord::Transitions + include ActiveModel::Transitions state_machine do event :replace, timestamp: 1 do transitions :from => :prepared, :to => :placed