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

failing test for custom actions with and without optional parents #202

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions test/url_helpers_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,14 @@ class ButtonsController < InheritedResources::Base
custom_actions :resource => :delete, :collection => :search
end

class PanelController < InheritedResources::Base
belongs_to :display, :optional => true do
belongs_to :window
end

custom_actions :resource => :lock, :collection => :search
end

class ImageButtonsController < ButtonsController
end

Expand Down Expand Up @@ -764,6 +772,33 @@ def test_url_helpers_with_custom_actions
controller.send("search_resources_#{path_or_url}")
end
end

def test_url_helpers_on_custom_actions_with_optional_parents
controller = PanelController.new
controller.instance_variable_set('@display', :display)
controller.instance_variable_set('@window', :window)
controller.instance_variable_set('@panel', :panel)
[:url, :path].each do |path_or_url|
controller.expects("lock_display_window_panel_#{path_or_url}").with(:panel, {}).once
controller.send("lock_resource_#{path_or_url}")

controller.expects("search_display_window_panels_#{path_or_url}").with(:window, {}).once
controller.send("search_resources_#{path_or_url}")
end
end

def test_url_helpers_on_custom_actions_without_optional_parents
controller = PanelController.new
controller.instance_variable_set('@window', :window)
controller.instance_variable_set('@panel', :panel)
[:url, :path].each do |path_or_url|
controller.expects("lock_window_panel_#{path_or_url}").with(:panel, {}).once
controller.send("lock_resource_#{path_or_url}")

controller.expects("search_window_panels_#{path_or_url}").with(:window, {}).once
controller.send("search_resources_#{path_or_url}")
end
end

def test_helper_methods_with_custom_actions
controller = ButtonsController.new
Expand Down