Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

using helpers from gem

  • Loading branch information...
commit 23e1ed6f4a28da70c69ced0ff1a40ce65790f561 1 parent b0be936
@NoamB NoamB authored
View
6 Gemfile
@@ -10,11 +10,13 @@ gem 'mysql2'
# Bundle the extra gems:
-gem 'sorcery', '0.4.1'
+gem 'sorcery', '0.4.2'
# Bundle gems for the local environment. Make sure to
# put test-only gems in this group so their generators
# and rake tasks are available in development mode:
group :development, :test do
-
+ gem "test-unit", "~> 2.3.0"
+ gem "rspec", "~> 2.5.0"
+ gem 'rspec-rails', "~> 2.5.0"
end
View
22 Gemfile.lock
@@ -32,6 +32,7 @@ GEM
arel (2.0.9)
bcrypt-ruby (2.1.4)
builder (2.1.2)
+ diff-lcs (1.1.2)
erubis (2.6.6)
abstract (>= 1.0.0)
faraday (0.5.7)
@@ -73,7 +74,20 @@ GEM
rake (>= 0.8.7)
thor (~> 0.14.4)
rake (0.8.7)
- sorcery (0.4.1)
+ rspec (2.5.0)
+ rspec-core (~> 2.5.0)
+ rspec-expectations (~> 2.5.0)
+ rspec-mocks (~> 2.5.0)
+ rspec-core (2.5.1)
+ rspec-expectations (2.5.0)
+ diff-lcs (~> 1.1.2)
+ rspec-mocks (2.5.0)
+ rspec-rails (2.5.0)
+ actionpack (~> 3.0)
+ activesupport (~> 3.0)
+ railties (~> 3.0)
+ rspec (~> 2.5.0)
+ sorcery (0.4.2)
bcrypt-ruby (~> 2.1.4)
json (>= 1.5.1)
oauth (>= 0.4.4)
@@ -81,6 +95,7 @@ GEM
oauth2 (>= 0.1.1)
oauth2 (>= 0.1.1)
rails (>= 3.0.0)
+ test-unit (2.3.0)
thor (0.14.6)
treetop (1.4.9)
polyglot (>= 0.3.1)
@@ -92,4 +107,7 @@ PLATFORMS
DEPENDENCIES
mysql2
rails (= 3.0.3)
- sorcery (= 0.4.1)
+ rspec (~> 2.5.0)
+ rspec-rails (~> 2.5.0)
+ sorcery (= 0.4.2)
+ test-unit (~> 2.3.0)
View
13 db/schema.rb
@@ -21,23 +21,20 @@
end
create_table "users", :force => true do |t|
- t.string "email", :null => false
- t.string "crypted_password"
- t.string "salt"
+ t.string "email", :null => false
+ t.string "crypted_password", :null => false
+ t.string "salt", :null => false
t.datetime "created_at"
t.datetime "updated_at"
t.string "activation_state"
t.string "activation_code"
- t.datetime "activation_code_expires_at"
t.string "remember_me_token"
t.datetime "remember_me_token_expires_at"
- t.string "reset_password_token"
- t.datetime "reset_password_token_expires_at"
- t.datetime "reset_password_email_sent_at"
+ t.string "reset_password_code"
t.datetime "last_login_at"
t.datetime "last_logout_at"
t.datetime "last_activity_at"
- t.integer "failed_logins_count", :default => 0
+ t.integer "failed_logins_count", :default => 0
t.datetime "lock_expires_at"
t.string "type"
end
View
10 test/fixtures/users.yml
@@ -1,8 +1,8 @@
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
-ben:
+noam:
email: whatever@whatever.com
- password_salt: <%= salt = Authlogic::Random.hex_token %>
- crypted_password: <%= Authlogic::CryptoProviders::Sha512.encrypt("benrocks" + salt) %>
- persistence_token: <%= Authlogic::Random.hex_token %>
- perishable_token: <%= Authlogic::Random.friendly_token %>
+ salt: <%= salt = "asdasdastr4325234324sdfds" %>
+ crypted_password: <%= Sorcery::CryptoProviders::BCrypt.encrypt("secret", salt) %>
+ activation_state: active
+ type: User
View
13 test/functional/user_sessions_controller_test.rb
@@ -1,6 +1,10 @@
require 'test_helper'
class UserSessionsControllerTest < ActionController::TestCase
+ setup do
+ @user = users(:noam)
+ end
+
test "should get new" do
get :new
assert_response :success
@@ -12,8 +16,15 @@ class UserSessionsControllerTest < ActionController::TestCase
end
test "should get destroy" do
+ login_user
get :destroy
- assert_response :success
+ assert_redirected_to :users
+ assert_equal("Logged out!", flash[:notice])
end
+ test "when logged out should not get destroy" do
+ logout_user
+ get :destroy
+ assert_redirected_to root_url
+ end
end
View
7 test/functional/users_controller_test.rb
@@ -1,8 +1,9 @@
require 'test_helper'
class UsersControllerTest < ActionController::TestCase
+
setup do
- @user = users(:ben)
+ @user = users(:noam)
end
test "should get index" do
@@ -25,21 +26,25 @@ class UsersControllerTest < ActionController::TestCase
end
test "should show user" do
+ login_user
get :show, :id => @user.to_param
assert_response :success
end
test "should get edit" do
+ login_user
get :edit, :id => @user.to_param
assert_response :success
end
test "should update user" do
+ login_user
put :update, :id => @user.to_param, :user => @user.attributes
assert_redirected_to user_path(assigns(:user))
end
test "should destroy user" do
+ login_user
assert_difference('User.count', -1) do
delete :destroy, :id => @user.to_param
end
View
2  test/test_helper.rb
@@ -1,7 +1,6 @@
ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
-require "authlogic/test_case"
class ActiveSupport::TestCase
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
@@ -11,4 +10,5 @@ class ActiveSupport::TestCase
fixtures :all
# Add more helper methods to be used by all tests here...
+ include Sorcery::TestHelpers::Rails
end
Please sign in to comment.
Something went wrong with that request. Please try again.