Sha256: 351482dcc6d5b3da38bee265a37d29cbaad8074d83e8d833cc28185edd613fe0

Contents?: true

Size: 913 Bytes

Versions: 25

Compression:

Stored size: 913 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 %> ? (<%= file_name %>.is_a?(<%= file_name.camelize %>) ? <%= file_name %>.id : <%= 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

25 entries across 25 versions & 5 rubygems

Version Path
genki-restful-authentication-1.1.1 generators/authenticated/templates/authenticated_test_helper.rb
smukherjee-openbill-0.1.5 vendor/plugins/restful-authentication/generators/authenticated/templates/authenticated_test_helper.rb
smukherjee-openbill-0.1.6 vendor/plugins/restful-authentication/generators/authenticated/templates/authenticated_test_helper.rb
smukherjee-openbill-0.1.7 vendor/plugins/restful-authentication/generators/authenticated/templates/authenticated_test_helper.rb
tournament-5.0.0 webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/authenticated_test_helper.rb
tournament-4.2.0 webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/authenticated_test_helper.rb
tournament-4.0.2 webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/authenticated_test_helper.rb
tournament-4.0.0 webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/authenticated_test_helper.rb
tournament-3.3.3 webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/authenticated_test_helper.rb
tournament-3.3.2 webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/authenticated_test_helper.rb
tournament-3.3.1 webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/authenticated_test_helper.rb
tournament-3.3.0 webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/authenticated_test_helper.rb
tournament-3.2.2 webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/authenticated_test_helper.rb
tournament-3.2.1 webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/authenticated_test_helper.rb
tournament-3.2.0 webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/authenticated_test_helper.rb
tournament-3.1.1 webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/authenticated_test_helper.rb
tournament-3.1.0 webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/authenticated_test_helper.rb
branston-0.4.1 lib/branston/vendor/plugins/restful_authentication/generators/authenticated/templates/authenticated_test_helper.rb
branston-0.4.0 lib/branston/vendor/plugins/restful_authentication/generators/authenticated/templates/authenticated_test_helper.rb
branston-0.3.6 lib/branston/vendor/plugins/restful_authentication/generators/authenticated/templates/authenticated_test_helper.rb