Commit 91d13ed2
Changed files (7)
app
controllers
app/controllers/api/v1/api_controller.rb
@@ -2,7 +2,6 @@ module Api
module V1
class ApiController < ApplicationController
before_filter :restrict_access
- attr_reader :current_user
private
app/controllers/application_controller.rb
@@ -24,4 +24,8 @@ class ApplicationController < ActionController::Base
@session = Session.find_by(id: cookies.signed[:cookie_monster])
redirect_to new_session_path unless @session
end
+
+ def current_user
+ @session.try(:user)
+ end
end
spec/features/add_to_favorites_spec.rb
@@ -7,8 +7,8 @@ describe "adding a cake to your favorites", :js => true do
before :each do
visit new_session_path
within('.form-inline') do
- fill_in('user_email', :with => me.email)
- fill_in('user_password', :with => "password")
+ fill_in('session_username', :with => me.email)
+ fill_in('session_password', :with => "password")
end
click_button("Sign In")
click_link(creation.name)
spec/features/change_password_spec.rb
@@ -7,8 +7,8 @@ describe "changing my password" do
before :each do
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")
visit my_settings_path
spec/features/change_profile_settings_spec.rb
@@ -6,8 +6,8 @@ describe "Change settings" do
before :each do
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")
visit my_settings_path
spec/features/logins_spec.rb
@@ -13,14 +13,14 @@ describe "Logins" do
before :each do
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")
end
it "should let the user signin with the proper password" do
- page.should have_content(I18n.t('devise.sessions.signed_in'))
+ page.should have_content("Log Out")
end
it "should not have an error" do
@@ -28,18 +28,18 @@ describe "Logins" do
end
end
- context "when an email is not known" do
+ context "when an email is not known", js: true do
before :each do
visit new_session_path
within('.form-inline') do
- fill_in('user_email', :with => 'test@example.com')
- fill_in('user_password', :with => 'password')
+ fill_in('session_username', :with => 'test@example.com')
+ fill_in('session_password', :with => 'password')
end
click_button "Sign In"
end
it "should display an error message" do
- page.should have_content(I18n.t('devise.failure.invalid'))
+ page.should have_content("invalid credentials")
end
end
end
spec/features/upload_avatar_spec.rb
@@ -6,8 +6,8 @@ describe "uploading an avatar" do
before :each do
visit new_session_path
within('.form-inline') do
- fill_in('user_email', :with => user.email)
- fill_in('user_password', :with => "password")
+ fill_in('sessions_username', :with => user.email)
+ fill_in('sessions_password', :with => "password")
end
click_button("Sign In")
visit edit_my_avatar_path(user)