0
@@ -4,110 +4,7 @@ module AuthenticatedTestHelper
0
@request.session[:<%= file_name %>] = <%= file_name %> ? <%= table_name %>(<%= file_name %>).id : nil
0
- def content_type(type)
0
- @request.env['Content-Type'] = type
0
- @request.env["HTTP_ACCEPT"] = accept
0
- @request.env["HTTP_AUTHORIZATION"] = "Basic #{Base64.encode64("#{users(user).login}:test")}"
0
- accept 'application/xml'
0
- content_type 'application/xml'
0
- @request.env["HTTP_AUTHORIZATION"] = nil
0
- # http://project.ioni.st/post/217#post-217
0
- # def test_new_publication
0
- # assert_difference(Publication, :count) do
0
- # post :create, :publication => {...}
0
- def assert_difference(object, method = nil, difference = 1)
0
- initial_value = object.send(method)
0
- assert_equal initial_value + difference, object.send(method), "#{object}##{method}"
0
- def assert_no_difference(object, method, &block)
0
- assert_difference object, method, 0, &block
0
- # Assert the block redirects to the login
0
- # assert_requires_login(:bob) { |c| c.get :edit, :id => 1 }
0
- def assert_requires_login(login = nil)
0
- yield HttpLoginProxy.new(self, login)
0
+ @request.env["HTTP_AUTHORIZATION"] = user ? "Basic #{Base64.encode64("#{users(user).login}:test")}" : nil
0
- def assert_http_authentication_required(login = nil)
0
- yield XmlLoginProxy.new(self, login)
0
- def reset!(*instance_vars)
0
- instance_vars = [:controller, :request, :response] unless instance_vars.any?
0
- instance_vars.collect! { |v| "@#{v}".to_sym }
0
- instance_vars.each do |var|
0
- instance_variable_set(var, instance_variable_get(var).class.new)
0
- attr_reader :controller
0
- def initialize(controller, login)
0
- @controller = controller
0
- raise NotImplementedError
0
- raise NotImplementedError
0
- def method_missing(method, *args)
0
- @controller.send(method, *args)
0
-class HttpLoginProxy < BaseLoginProxy
0
- @controller.login_as @login if @login
0
- @controller.assert_redirected_to :controller => 'sessions', :action => 'new'
0
-class XmlLoginProxy < BaseLoginProxy
0
- @controller.accept 'application/xml'
0
- @controller.authorize_as @login if @login
0
- @controller.assert_response 401
0
\ No newline at end of file
Comments
No one has commented yet.