Sha256: 51e0d3092a3cb55105d0c1da620cb768bcdd29f75b0c6ff21a51d28d5dd51e28

Contents?: true

Size: 1.3 KB

Versions: 46

Compression:

Stored size: 1.3 KB

Contents

require 'spec_helper'

describe Admin::PostsController, "Controller Authorization", :type => :controller do

  let(:user) { AdminUser.create!(:email => "example@admin.com", :password => "password", :password_confirmation => "password") }
  let(:app) { ActiveAdmin.application }
  let(:authorization){ controller.send(:active_admin_authorization) }

  before do
  # TODO: Get these tests passing...
    pending

    load_defaults!
    @request.env["devise.mapping"] = Devise.mappings[:admin]
    @resource.namespace.current_user_method = :current_admin_user

    sign_in(user)
  end

  it "should authorize the index action" do
    authorization.should_receive(:authorized?).
      with(ActiveAdmin::Authorization::READ, Post).
      and_return(true)

    get :index
  end

  it "should authorize the new action" do
    authorization.should_receive(:authorized?).
      with(ActiveAdmin::Authorization::CREATE, an_instance_of(Post)).
      and_return(true)

    get :new
  end

  it "should authorize the create action with the new resource" do
    mock_post = mock("Post", :save => true, :errors => [])
    Post.should_receive(:new).at_least(:once).and_return(mock_post)

    authorization.should_receive(:authorized?).
      with(ActiveAdmin::Authorization::CREATE, mock_post).
      and_return(true)

    post :create
  end

end

Version data entries

46 entries across 46 versions & 2 rubygems

Version Path
lalala-4.0.0.dev.141 vendor/deps/active_admin/spec/unit/authorization/controller_authorization_spec.rb
lalala-4.0.0.dev.136 vendor/deps/active_admin/spec/unit/authorization/controller_authorization_spec.rb
lalala-4.0.0.dev.135 vendor/deps/active_admin/spec/unit/authorization/controller_authorization_spec.rb
lalala-4.0.0.dev.134 vendor/deps/active_admin/spec/unit/authorization/controller_authorization_spec.rb
lalala-4.0.0.dev.133 vendor/deps/active_admin/spec/unit/authorization/controller_authorization_spec.rb
lalala-4.0.0.dev.132 vendor/deps/active_admin/spec/unit/authorization/controller_authorization_spec.rb
lalala-4.0.0.dev.131 vendor/deps/active_admin/spec/unit/authorization/controller_authorization_spec.rb
lalala-4.0.0.dev.129 vendor/deps/active_admin/spec/unit/authorization/controller_authorization_spec.rb
lalala-4.0.0.dev.128 vendor/deps/active_admin/spec/unit/authorization/controller_authorization_spec.rb
lalala-4.0.0.dev.126 vendor/deps/active_admin/spec/unit/authorization/controller_authorization_spec.rb
lalala-4.0.0.dev.125 vendor/deps/active_admin/spec/unit/authorization/controller_authorization_spec.rb
lalala-4.0.0.dev.124 vendor/deps/active_admin/spec/unit/authorization/controller_authorization_spec.rb
lalala-4.0.0.dev.123 vendor/deps/active_admin/spec/unit/authorization/controller_authorization_spec.rb
lalala-4.0.0.dev.118 vendor/deps/active_admin/spec/unit/authorization/controller_authorization_spec.rb
lalala-4.0.0.dev.116 vendor/deps/active_admin/spec/unit/authorization/controller_authorization_spec.rb
lalala-4.0.0.dev.114 vendor/deps/active_admin/spec/unit/authorization/controller_authorization_spec.rb
lalala-4.0.0.dev.113 vendor/deps/active_admin/spec/unit/authorization/controller_authorization_spec.rb
lalala-4.0.0.dev.111 vendor/deps/active_admin/spec/unit/authorization/controller_authorization_spec.rb
lalala-4.0.0.dev.109 vendor/deps/active_admin/spec/unit/authorization/controller_authorization_spec.rb
lalala-4.0.0.dev.107 vendor/deps/active_admin/spec/unit/authorization/controller_authorization_spec.rb