specstar-controllers 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/specstar/controllers.rb +9 -6
- metadata +1 -1
data/lib/specstar/controllers.rb
CHANGED
@@ -17,14 +17,17 @@ module Specstar
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
+
def has_skip_before_filter_for_action?(controller, filter, action)
|
21
|
+
controller._process_action_callbacks.any? { |callback|
|
22
|
+
callback.chain.any? { |chain|
|
23
|
+
chain.kind == :before && chain.filter.to_s == filter.to_s && chain.per_key[:unless].any? { |item| item.include? "action_name == '#{action}'" }
|
24
|
+
}
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
20
28
|
def has_skip_before_filter?(controller, filter, actions)
|
21
29
|
if actions.present?
|
22
|
-
|
23
|
-
callback.chain.select { |chain|
|
24
|
-
actions_match = actions.select { |action| !chain.per_key[:unless].include?("action_name == '#{action}'") }.empty?
|
25
|
-
chain.kind == :before && chain.filter.to_s == filter.to_s && actions_match
|
26
|
-
}.size > 0
|
27
|
-
}.size > 0
|
30
|
+
actions.all? { |action| has_skip_before_filter_for_action?(controller, filter, action) }
|
28
31
|
else
|
29
32
|
!has_before_filter?(controller, filter)
|
30
33
|
end
|