Sha256: a0466fc2fa4f88f1f738da5423ce121ce179e44da221d3918098225948853387

Contents?: true

Size: 1.18 KB

Versions: 17

Compression:

Stored size: 1.18 KB

Contents

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

describe Octopus::Controller do
  it "should have the using method to select the shard" do
    a = ActionController::Base.new
    a.respond_to?(:using).should be_true
  end
  
  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
        using(:brazil) do
          yield
        end
      end
      
      def self._router
        ActionDispatch::Routing::RouteSet.new
      end      
    end
    
    UsersControllers.action_methods.include?("create").should be_true
    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
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
ar-octopus-0.0.19 spec/octopus/controller_spec.rb
ar-octopus-0.0.18 spec/octopus/controller_spec.rb
ar-octopus-0.0.16 spec/octopus/controller_spec.rb
ar-octopus-0.0.15 spec/octopus/controller_spec.rb
ar-octopus-0.0.14 spec/octopus/controller_spec.rb
ar-octopus-0.0.13 spec/octopus/controller_spec.rb
ar-octopus-0.0.12 spec/octopus/controller_spec.rb
ar-octopus-0.0.11 spec/octopus/controller_spec.rb
ar-octopus-0.0.10 spec/octopus/controller_spec.rb
ar-octopus-0.0.9 spec/octopus/controller_spec.rb
ar-octopus-0.0.8 spec/octopus/controller_spec.rb
ar-octopus-0.0.7 spec/octopus/controller_spec.rb
ar-octopus-0.0.6 spec/octopus/controller_spec.rb
ar-octopus-0.0.5 spec/octopus/controller_spec.rb
ar-octopus-0.0.4 spec/octopus/controller_spec.rb
ar-octopus-0.0.3 spec/octopus/controller_spec.rb
ar-octopus-0.0.2 spec/octopus/controller_spec.rb