Sha256: 8d1db6daf5d1364d5a5e3d0907f367b2b0464152e3e92306319af8039f052e16

Contents?: true

Size: 1.09 KB

Versions: 12

Compression:

Stored size: 1.09 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe "Rails Controllers" do
  it "should use #using method to in all requests" do
    class UsersControllers < ActionController::Base
      around_filter :select_shard      
      def create
        User.create!(:name => "ActionController")
        render :nothing => true
      end
      
      def select_shard(&block)
        Octopus.using(:brazil, &block)
      end
      
      def self._routes
        ActionDispatch::Routing::RouteSet.new
      end      
    end
    
    UsersControllers.action_methods.include?("create").should be_true

    if Octopus.rails3?
      a = UsersControllers.new
      a.stub!(:request).and_return(mock({:fullpath => "", :filtered_parameters => {}, :formats => ["xml"], :method => "GET"}))
      a.instance_variable_set(:@_response, mock(:content_type => "xml", :body= => "", :status => 401))
      a.process(:create)
      User.using(:brazil).find_by_name("ActionController").should_not be_nil
      User.using(:master).find_by_name("ActionController").should be_nil
    else
      pending()
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
ar-octopus-0.3.4 spec/octopus/controller_spec.rb
ar-octopus-0.3.3 spec/octopus/controller_spec.rb
ar-octopus-0.3.2 spec/octopus/controller_spec.rb
ar-octopus-0.3.1 spec/octopus/controller_spec.rb
ar-octopus-0.3.0 spec/octopus/controller_spec.rb
ar-octopus-0.2.2 spec/octopus/controller_spec.rb
ar-octopus-0.2.1 spec/octopus/controller_spec.rb
ar-octopus-0.2.0 spec/octopus/controller_spec.rb
ar-octopus-0.1.2 spec/octopus/controller_spec.rb
ar-octopus-0.1.1 spec/octopus/controller_spec.rb
ar-octopus-0.1.0 spec/octopus/controller_spec.rb
ar-octopus-0.0.30 spec/octopus/controller_spec.rb