Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix and implement missing resource controller specs #3356

Merged
merged 4 commits into from Aug 31, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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