some updates
This commit is contained in:
parent
3ffc64cc48
commit
8b98a0b4c6
|
@ -58,6 +58,10 @@ def find_action(action)
|
||||||
find("[data-action='#{action}']")
|
find("[data-action='#{action}']")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def find_object_action(object, action)
|
||||||
|
find("[data-type='#{object}'][data-action='#{action}']")
|
||||||
|
end
|
||||||
|
|
||||||
module Capybara
|
module Capybara
|
||||||
class ElementFound < StandardError
|
class ElementFound < StandardError
|
||||||
def initialize(search)
|
def initialize(search)
|
||||||
|
@ -115,11 +119,15 @@ def within_any(search, &block)
|
||||||
search = "[data-type='#{search}']"
|
search = "[data-type='#{search}']"
|
||||||
end
|
end
|
||||||
|
|
||||||
all(search).each_with_index do |node, index|
|
nodes = all(search)
|
||||||
|
|
||||||
|
raise Capybara::ElementNotFound if nodes.empty?
|
||||||
|
|
||||||
|
nodes.each_with_index do |node, index|
|
||||||
begin
|
begin
|
||||||
within("#{search}:eq(#{index + 1})", &block)
|
within("#{search}:eq(#{index + 1})", &block)
|
||||||
return true
|
return true
|
||||||
rescue RSpec::Expectations::ExpectationNotMetError
|
rescue RSpec::Expectations::ExpectationNotMetError, Capybara::ElementNotFound
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ module SemanticRailsViewHelpers
|
||||||
def link_to_model_action(model, action = :show, options = {})
|
def link_to_model_action(model, action = :show, options = {})
|
||||||
target_action = action
|
target_action = action
|
||||||
|
|
||||||
label = options.delete(:label) || t(".#{action}")
|
label = options.delete(:label) || t(".#{model.class.name.underscore}.#{action}")
|
||||||
|
|
||||||
if action == :destroy
|
if action == :destroy
|
||||||
options = options.merge(:method => :delete, 'data-skip-pjax' => 'true')
|
options = options.merge(:method => :delete, 'data-skip-pjax' => 'true')
|
||||||
|
@ -52,7 +52,7 @@ module SemanticRailsViewHelpers
|
||||||
route = model
|
route = model
|
||||||
route = route.to_route if route.respond_to?(:to_route)
|
route = route.to_route if route.respond_to?(:to_route)
|
||||||
|
|
||||||
link_to label, polymorphic_url(route, :action => action), options.merge(semantic_action_data(target_action))
|
link_to label, polymorphic_url(route, :action => action), options.merge(semantic_action_data(target_action).merge(semantic_model_data(model)))
|
||||||
end
|
end
|
||||||
|
|
||||||
def li_for(object, options = {}, &block)
|
def li_for(object, options = {}, &block)
|
||||||
|
|
Loading…
Reference in New Issue