Sha256: 2ab04bf3dab93e8d00394cdc530d7d3555a5ac9e7f384251b35bea9f70e69863

Contents?: true

Size: 1.24 KB

Versions: 35

Compression:

Stored size: 1.24 KB

Contents

module ControllerMacros
  def self.included(base)
    base.extend(ClassMethods)
  end

  module ClassMethods
    def it_should_require_login_for_actions(*actions)
      actions.each do |action|
        it "#{action} should redirect if no user signed in" do
          get action
          response.should_not be_success
        end
      end
    end

    def it_should_redirect_to_app_main_for_actions(*actions)
      actions.each do |action|
        it "#{action} should redirect if no user signed in" do
          get action
          response.should redirect_to IuguSDK::app_main_url
        end
      end
    end

    def login_as_user
      before(:each) do
        @request.env["devise.mapping"] = Devise.mappings[:user]
        #user = @user if @user
        #if user.nil?
          #user = Fabricate(:user, :email => "teste@teste2.com", :password => "123456", :password_confirmation => "123456" )
          #@user = user
        #end
        @user ||= Fabricate(:user, email: "teste@teste.com", password: "123456", password_confirmation: "123456")
        account = Fabricate(:account)
        account.account_users << Fabricate(:account_user, :user => @user, :account => account)
        sign_in @user
        set_account @user
      end
    end
  end

end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
iugusdk-1.0.11 spec/controller_macros.rb
iugusdk-1.0.10 spec/controller_macros.rb
iugusdk-1.0.9 spec/controller_macros.rb
iugusdk-1.0.8 spec/controller_macros.rb
iugusdk-1.0.7 spec/controller_macros.rb
iugusdk-1.0.6 spec/controller_macros.rb
iugusdk-1.0.5 spec/controller_macros.rb
iugusdk-1.0.4 spec/controller_macros.rb
iugusdk-1.0.3 spec/controller_macros.rb
iugusdk-1.0.2 spec/controller_macros.rb
iugusdk-1.0.1 spec/controller_macros.rb
iugusdk-1.0.0.alpha.32 spec/controller_macros.rb
iugusdk-1.0.0.alpha.31 spec/controller_macros.rb
iugusdk-1.0.0.alpha.30 spec/controller_macros.rb
iugusdk-1.0.0.alpha.29 spec/controller_macros.rb
iugusdk-1.0.0.alpha.28 spec/controller_macros.rb
iugusdk-1.0.0.alpha.27 spec/controller_macros.rb
iugusdk-1.0.0.alpha.26 spec/controller_macros.rb
iugusdk-1.0.0.alpha.25 spec/controller_macros.rb
iugusdk-1.0.0.alpha.24 spec/controller_macros.rb