Sha256: b9a2e04577161d46e0d67833ebd5deaf08146df9247a78acdf39727fb91cc5e4

Contents?: true

Size: 837 Bytes

Versions: 21

Compression:

Stored size: 837 Bytes

Contents

module AuthenticatedTestHelper
  # Sets the current <%= file_name %> in the session from the <%= file_name %> fixtures.
  def login_as(<%= file_name %>)
    @request.session[:<%= file_name %>_id] = <%= file_name %> ? <%= table_name %>(<%= file_name %>).id : nil
  end

  def authorize_as(<%= file_name %>)
    @request.env["HTTP_AUTHORIZATION"] = <%= file_name %> ? ActionController::HttpAuthentication::Basic.encode_credentials(<%= table_name %>(<%= file_name %>).login, 'monkey') : nil
  end
  
<% if options[:rspec] -%>
  # rspec
  def mock_<%= file_name %>
    <%= file_name %> = mock_model(<%= class_name %>, :id => 1,
      :login  => 'user_name',
      :name   => 'U. Surname',
      :to_xml => "<%= class_name %>-in-XML", :to_json => "<%= class_name %>-in-JSON", 
      :errors => [])
    <%= file_name %>
  end  
<% end -%>
end

Version data entries

21 entries across 21 versions & 5 rubygems

Version Path
dwaite-restful-authentication-1.1.1 generators/authenticated/templates/authenticated_test_helper.rb
ggoodale-restful-authentication-1.1.1 generators/authenticated/templates/authenticated_test_helper.rb
jcnetdev-restful-authentication-1.0.20080704 generators/authenticated/templates/authenticated_test_helper.rb
simonmenke-mr_authentication-0.0.1 vendor/plugins/restful-authentication/generators/authenticated/templates/authenticated_test_helper.rb
tournament-3.0.3 webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/authenticated_test_helper.rb
tournament-3.0.2 webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/authenticated_test_helper.rb
tournament-3.0.1 webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/authenticated_test_helper.rb
tournament-3.0.0 webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/authenticated_test_helper.rb
tournament-2.1.0 webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/authenticated_test_helper.rb
tournament-2.2.0 webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/authenticated_test_helper.rb
tournament-2.2.1 webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/authenticated_test_helper.rb
tournament-2.0.0 webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/authenticated_test_helper.rb
tournament-2.1.1 webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/authenticated_test_helper.rb
tournament-2.1.2 webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/authenticated_test_helper.rb
tournament-2.2.2 webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/authenticated_test_helper.rb
tournament-2.4.0 webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/authenticated_test_helper.rb
tournament-2.3.0 webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/authenticated_test_helper.rb
tournament-2.5.0 webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/authenticated_test_helper.rb
tournament-2.5.2 webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/authenticated_test_helper.rb
tournament-2.5.1 webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/authenticated_test_helper.rb