Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 23b5f83a66
Fetching contributors…

Cannot retrieve contributors at this time

89 lines (78 sloc) 2.458 kb
require 'spec_helper'
describe 'defining new actions from registration blocks' do
let(:controller){ Admin::PostsController }
describe "generating a new member action" do
before do
action!
reload_routes!
end
after(:each) do
controller.clear_member_actions!
end
context "with a block" do
let(:action!) do
ActiveAdmin.register Post do
member_action :comment do
# Do nothing
end
end
end
it "should create a new public instance method" do
controller.public_instance_methods.collect(&:to_s).should include("comment")
end
it "should add itself to the member actions config" do
controller.active_admin_config.member_actions.size.should == 1
end
it "should create a new named route" do
Rails.application.routes.url_helpers.methods.collect(&:to_s).should include("comment_admin_post_path")
end
end
context "without a block" do
let(:action!) do
ActiveAdmin.register Post do
member_action :comment
end
end
it "should still generate a new empty action" do
controller.public_instance_methods.collect(&:to_s).should include("comment")
end
end
end
describe "generate a new collection action" do
before do
action!
reload_routes!
end
after(:each) do
controller.clear_collection_actions!
end
context "with a block" do
let(:action!) do
ActiveAdmin.register Post do
collection_action :comments do
# Do nothing
end
end
end
it "should create a new public instance method" do
controller.public_instance_methods.collect(&:to_s).should include("comments")
end
it "should add itself to the member actions config" do
controller.active_admin_config.collection_actions.size.should == 1
end
it "should create a new named route" do
Rails.application.routes.url_helpers.methods.collect(&:to_s).should include("comments_admin_posts_path")
end
end
context "without a block" do
let(:action!) do
ActiveAdmin.register Post do
collection_action :comments
end
end
it "should still generate a new empty action" do
controller.public_instance_methods.collect(&:to_s).should include("comments")
end
end
end
end
Jump to Line
Something went wrong with that request. Please try again.