Skip to content

Commit

Permalink
Merge pull request #3356 from timoschilling/specs
Browse files Browse the repository at this point in the history
fix and implement missing resource controller specs
  • Loading branch information
seanlinsley committed Aug 31, 2014
2 parents d4b4e7f + f41c7c0 commit 28a0c1c
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions spec/unit/resource_controller_spec.rb
Expand Up @@ -224,36 +224,34 @@ def call_after_destroy(obj); end

describe "performing batch_action" do
let(:controller){ Admin::PostsController.new }
let(:batch_action) { ActiveAdmin::BatchAction.new :flag, "Flag", &batch_action_block }
let(:batch_action_block) { proc { } }
before do
batch_action = ActiveAdmin::BatchAction.new :flag, "Flag" do
redirect_to collection_path
end

allow(controller.class.active_admin_config).to receive(:batch_actions).and_return([batch_action])
end

describe "when params batch_action matches existing BatchAction" do
it "should call the block with args" do
skip # dont know how to check if the block was called
allow(controller).to receive(:params) { { batch_action: "flag", collection_selection: ["1"] } }
expect(controller).to receive(:instance_exec).with(["1"], {})
controller.batch_action
end
end

describe "when params batch_action doesn't match a BatchAction" do
it "should raise an error" do
skip # doesn't pass when running whole spec suite (WTF)

allow(controller).to receive(:params) { { batch_action: "derp", collection_selection: ["1"] } }
expect {
post(:batch_action, batch_action: "derp", collection_selection: ["1"])
controller.batch_action
}.to raise_error("Couldn't find batch action \"derp\"")
end
end

describe "when params batch_action is blank" do
it "should raise an error" do
skip # doesn't pass when running whole spec suite (WTF)

allow(controller).to receive(:params) { { collection_selection: ["1"] } }
expect {
post(:batch_action, collection_selection: ["1"])
controller.batch_action
}.to raise_error("Couldn't find batch action \"\"")
end
end
Expand Down

0 comments on commit 28a0c1c

Please sign in to comment.