Skip to content

Instantly share code, notes, and snippets.

@fujimura
Created January 15, 2010 09:45
Show Gist options
  • Save fujimura/277930 to your computer and use it in GitHub Desktop.
Save fujimura/277930 to your computer and use it in GitHub Desktop.
class Test::Unit::TestCase
def self.should_require_login(http_method, method)
should "require login wth #{http_method.to_s.upcase} :#{method}" do
raise "http verb(#{http_method} is not my cup of tea)" unless [:put, :get, :post, :delete].include? http_method.to_sym
if UserSession.find
UserSession.find.destroy
end
eval(http_method.to_s + "(\"#{method}\")")
assert_redirected_to new_user_session_path
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment