Commit 537d150e
Changed files (14)
app
app/controllers/my/base_controller.rb
@@ -1,5 +1,5 @@
module My
class BaseController < ApplicationController
- before_filter :authenticate_user!
+ before_filter :authenticate!
end
end
app/controllers/application_controller.rb
@@ -19,4 +19,9 @@ class ApplicationController < ActionController::Base
@newest_members = User.order(:created_at => :desc).limit(3)
@top_members = User.order(:creations_count => :desc).limit(3)
end
+
+ def authenticate!
+ @session = Session.find_by(id: cookies.signed[:cookie_monster])
+ redirect_to new_session_path unless @session
+ end
end
app/controllers/favorites_controller.rb
@@ -1,5 +1,5 @@
class FavoritesController < ApplicationController
- before_filter :authenticate_user!
+ before_filter :authenticate!
def index
@creation = FindCreationQuery.new.fetch(params[:creation_id])
app/controllers/profiles_controller.rb
@@ -1,5 +1,5 @@
class ProfilesController < ApplicationController
- before_filter :authenticate_user!, :except => [:index, :show]
+ before_filter :authenticate!, :except => [:index, :show]
def index
@profiles = User.includes(:avatar).where('creations_count > 0').order(:creations_count => :desc).page(params[:page]).per(12)
app/controllers/tutorials_controller.rb
@@ -1,5 +1,5 @@
class TutorialsController < ApplicationController
- before_filter :authenticate_user!, :except => [:show, :index]
+ before_filter :authenticate!, :except => [:show, :index]
def index
@tutorials = Tutorial.includes(:tags).page(params[:page]).per(15)
spec/controllers/tutorials_controller_spec.rb
@@ -8,7 +8,7 @@ describe TutorialsController do
let(:user){ create(:user) }
before (:each) do
- request.env['warden'] = double(Warden, :authenticate => user, :authenticate! => user)
+ http_login(user)
end
describe "#index" do
spec/features/add_to_favorites_spec.rb
@@ -5,7 +5,7 @@ describe "adding a cake to your favorites", :js => true do
let!(:me) { create(:user, :password => "password") }
before :each do
- visit user_session_path
+ visit new_session_path
within('.form-inline') do
fill_in('user_email', :with => me.email)
fill_in('user_password', :with => "password")
spec/features/change_password_spec.rb
@@ -5,7 +5,7 @@ describe "changing my password" do
let(:user) { create(:user, :password => "password") }
before :each do
- visit user_session_path
+ visit new_session_path
within('.form-inline') do
fill_in('user_email', :with => user.email)
fill_in('user_password', :with => "password")
spec/features/change_profile_settings_spec.rb
@@ -4,7 +4,7 @@ describe "Change settings" do
let(:user) { create(:user, :password => "password") }
before :each do
- visit user_session_path
+ visit new_session_path
within('.form-inline') do
fill_in('user_email', :with => user.email)
fill_in('user_password', :with => "password")
spec/features/forgot_password_spec.rb
@@ -5,7 +5,7 @@ describe "password retrieval", :js => true do
let(:user) { create(:user) }
before :each do
- visit user_session_path
+ visit new_session_path
click_link "Forgot your password?"
within "#new_user" do
fill_in "user_email", :with => user.email
spec/features/logins_spec.rb
@@ -3,7 +3,7 @@ require 'rails_helper'
describe "Logins" do
describe "GET /login" do
it "should be able to reach the login page" do
- visit user_session_path
+ visit new_session_path
page.should have_content("Got an account? Login!")
end
@@ -11,7 +11,7 @@ describe "Logins" do
let!(:user) { create(:user, :password => "password") }
before :each do
- visit user_session_path
+ visit new_session_path
within('.form-inline') do
fill_in('user_email', :with => user.email)
fill_in('user_password', :with => "password")
@@ -30,7 +30,7 @@ describe "Logins" do
context "when an email is not known" do
before :each do
- visit user_session_path
+ visit new_session_path
within('.form-inline') do
fill_in('user_email', :with => 'test@example.com')
fill_in('user_password', :with => 'password')
spec/features/upload_avatar_spec.rb
@@ -4,7 +4,7 @@ describe "uploading an avatar" do
let(:user) { create(:user, :password => "password") }
before :each do
- visit user_session_path
+ visit new_session_path
within('.form-inline') do
fill_in('user_email', :with => user.email)
fill_in('user_password', :with => "password")
spec/features/upload_creation_spec.rb
@@ -6,10 +6,10 @@ describe "uploading a new creation", :js => true do
let!(:category_2) { create(:category) }
before :each do
- visit user_session_path
+ visit new_session_path
within('.form-inline') do
- fill_in('user_email', with: user.email)
- fill_in('user_password', with: "password")
+ fill_in('session_username', with: user.email)
+ fill_in('session_password', with: "password")
end
click_button("Sign In")
click_link("Add Creation")
spec/support/devise_helper.rb
@@ -1,11 +1,9 @@
module DeviseHelper
module Controllers
def http_login(user)
- gateway = double
- gateway.stub(:authenticate).and_return(user)
- gateway.stub(:authenticate!).and_return(user)
- gateway.stub(:authenticate?).and_return(user)
- request.env['warden'] = gateway
+ new_session = Session.new
+ controller.stub(:authenticate!).and_return(new_session)
+ controller.stub(:current_user).and_return(user)
end
end
end