Newer
Older
# Copyright (c) 2010-2011, Diaspora Inc. This file is
zhitomirskiyi
a validé
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
require 'spec_helper'
zhitomirskiyi
a validé
describe SessionsController do
include Devise::TestHelpers
let(:mock_access_token) { Object.new }
before do
zhitomirskiyi
a validé
@request.env["devise.mapping"] = Devise.mappings[:user]
zhitomirskiyi
a validé
@user.password = "evankorth"
@user.password_confirmation = "evankorth"
zhitomirskiyi
a validé
@user.save
end
describe "#create" do
it "redirects to root_path for a non-mobile user" do
post :create, {"user" => {"remember_me" => "0", "username" => @user.username, "password" => "evankorth"}}
response.location.should match /^#{root_url}\??$/
@request.env['HTTP_USER_AGENT'] = 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_1 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8B117 Safari/6531.22.7'
post :create, {"user" => {"remember_me" => "0", "username" => @user.username, "password" => "evankorth"}}
response.location.should match /^#{root_url}\??$/
end
describe "#destroy" do
before do
sign_in :user, @user
end
it "redirects to / for a non-mobile user" do
delete :destroy
response.should redirect_to new_user_session_path
end
it "redirects to / for a mobile user" do
@request.env['HTTP_USER_AGENT'] = 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_1 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8B117 Safari/6531.22.7'
delete :destroy
response.should redirect_to root_path
zhitomirskiyi
a validé
end
end