respond_to do |format|
format.html { redirect_to :controller => "account", :action => "login", :back_url => url }
format.atom { redirect_to :controller => "account", :action => "login", :back_url => url }
- format.xml { head :unauthorized }
- format.json { head :unauthorized }
+ format.xml { head :unauthorized, 'WWW-Authenticate' => 'Basic realm="Redmine API"' }
+ format.json { head :unauthorized, 'WWW-Authenticate' => 'Basic realm="Redmine API"' }
end
return false
end
assert_equal User.anonymous, User.current
end
end
+
+ context "without credentials" do
+ setup do
+ get "/projects/onlinestore/news.xml"
+ end
+
+ should_respond_with :unauthorized
+ should_respond_with_content_type :xml
+ should "include_www_authenticate_header" do
+ assert @controller.response.headers.has_key?('WWW-Authenticate')
+ end
+ end
end
context "in :json format" do
end
end
+ context "without credentials" do
+ setup do
+ get "/projects/onlinestore/news.json"
+ end
+
+ should_respond_with :unauthorized
+ should_respond_with_content_type :json
+ should "include_www_authenticate_header" do
+ assert @controller.response.headers.has_key?('WWW-Authenticate')
+ end
+ end
end
end