Skip to content

Commit

Permalink
Merge pull request #128 from compactcode/action_controller_layout_unu…
Browse files Browse the repository at this point in the history
…sed_fix

Mark action_controller layout methods as used.
  • Loading branch information
flyerhzm committed Aug 14, 2012
2 parents eba0c5b + 11acb73 commit ce73dd5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
Expand Up @@ -60,6 +60,11 @@ def start_command(node)
end
when "around_filter"
node.arguments.all.each { |argument| mark_used(argument) }
when "layout"
first_argument = node.arguments.all.first
if first_argument.sexp_type == :symbol_literal
mark_used(first_argument)
end
when "helper_method"
node.arguments.all.each { |argument| mark_publicize(argument.to_s) }
when "delegate"
Expand Down
Expand Up @@ -80,6 +80,28 @@ def set_timestamp
runner.should have(0).errors
end

it "should not remove unused methods for layout" do
content =<<-EOF
RailsBestPracticesCom::Application.routes.draw do
resources :posts
end
EOF
runner.prepare('config/routes.rb', content)
content =<<-EOF
class PostsController < ActiveRecord::Base
layout :choose_layout
private
def choose_layout
"default"
end
end
EOF
runner.prepare('app/controllers/posts_controller.rb', content)
runner.review('app/controllers/posts_controller.rb', content)
runner.after_review
runner.should have(0).errors
end

it "should not remove inherited_resources methods" do
content =<<-EOF
RailsBestPracticesCom::Application.routes.draw do
Expand Down

0 comments on commit ce73dd5

Please sign in to comment.