Better speccing

This commit is contained in:
2013-11-06 15:58:23 +01:00
parent 30ff19bdb4
commit 0928961423
5 changed files with 49 additions and 23 deletions
@@ -1,5 +1,6 @@
module Admin
class UsersController < Admin::ApplicationController
skip_before_filter :authenticate_administrator!, only: :test_login
# GET /users
# GET /users.json
def index
@@ -22,6 +23,14 @@ module Admin
end
end
def test_login
if Rails.env.test? and user = User.find_by_email(params[:email])
sign_in user
end
render nothing: true
end
# GET /users/new
# GET /users/new.json
def new
+5 -1
View File
@@ -3,7 +3,11 @@ Qwaiter::Application.routes.draw do
devise_for :suppliers, controllers: { confirmations: 'confirmations' }
devise_for :administrators
namespace :admin do
resources :users
resources :users do
collection do
get :test_login
end
end
resources :suppliers
resources :tables
resources :orders
@@ -4,13 +4,15 @@ Feature: Sign up as user using facebook
Scenario: Happy flow
Given There is no user information stored in the local storage
When I visit the user obtain token path
Then I should be signed in as a user
Then I should be signed in as a user through facebook
And I wait 4 seconds
And I should be redirected to the user home
And the newly created user info should be stored in the local storage
@broken
@javascript
Scenario: Already signed in user visits obtain token path
Given I am signed in as a user
And There is no user information stored in the local storage
When I visit '/user'
And I wait 4 seconds
Then I should be redirected to the user home
And the newly created user info should be stored in the local storage
+4
View File
@@ -9,6 +9,10 @@ step "I click on translation :translation" do |translation_key|
click_on text
end
step 'I visit :path' do |path|
visit path
end
step "I wait :number second/seconds" do |number|
sleep number.to_f
end
@@ -1,22 +1,29 @@
step "There is no user information stored in the local storage" do
page.evaluate_script(%|Qstorage.getItem('user_id')|).should be_blank
page.evaluate_script(%|Qstorage.getItem('auth_token')|).should be_blank
end
step "I visit the user obtain token path" do
visit user_obtain_token_path
end
step "I should be signed in as a user" do
step "I am signed in as a user" do
@user ||= create :user
visit test_login_admin_users_path(email: @user.email)
end
step "I should be signed in as a user through facebook" do
@user = User.find_by_oauth_token 'fbAuthToken234'
page.evaluate_script(%|Qstorage.getItem('user_id')|).should == @user.id
page.evaluate_script(%|Qstorage.getItem('auth_token')|).should == @user.authentication_token
binding.pry
# For now, actually better to test a signed in response from the server
step "the newly created user info should be stored in the local storage"
end
step "I should be redirected to the user home" do
page.current_path.should == user_root_path
end
step "the newly created user info should be stored in the local storage" do
page.evaluate_script(%|Qstorage.getItem('user_id')|).should == @user.id
page.evaluate_script(%|Qstorage.getItem('auth_token')|).should == @user.authentication_token
end