Permalink
Browse files

fixing some specs

  • Loading branch information...
1 parent ba30e86 commit 8806f9d0717cc020bfb5625fd1eaabac38f1c99c @NoamB committed Apr 13, 2012
View
@@ -51,6 +51,7 @@ task :all_sorcery_specs do
directory_name = File.dirname(rakefile)
sh <<-CMD
cd #{directory_name}
+ bundle
bundle exec rake
CMD
end
@@ -6,6 +6,7 @@ def self.up
end
def self.down
+ remove_column :users, :unlock_token
remove_column :users, :lock_expires_at
remove_column :users, :failed_logins_count
end
@@ -22,6 +22,11 @@
Timecop.return
end
+ it "should count login retries" do
+ 3.times {get :test_login, :username => 'gizmo', :password => 'blabla'}
+ User.find_by_username('gizmo').failed_logins_count.should == 3
+ end
+
it "should generate unlock token after user locked" do
sorcery_model_property_set(:consecutive_login_retries_amount_limit, 2)
sorcery_model_property_set(:login_lock_time_period, 0)
@@ -42,11 +47,7 @@
user.unlock!
User.load_from_unlock_token(token).should be_nil
end
-
- it "should count login retries" do
- 3.times {get :test_login, :username => 'gizmo', :password => 'blabla'}
- User.find_by_username('gizmo').failed_logins_count.should == 3
- end
+
it "should reset the counter on a good login" do
sorcery_model_property_set(:consecutive_login_retries_amount_limit, 5)
@@ -26,25 +26,25 @@
now = Time.now.utc
login_user
@user.last_login_at.should_not be_nil
- @user.last_login_at.to_s.should >= now.to_s
- @user.last_login_at.to_s.should <= (now+2).to_s
+ @user.last_login_at.utc.to_s.should >= now.utc.to_s
+ @user.last_login_at.utc.to_s.should <= (now.utc+2).to_s
end
it "should log logout time on logout" do
login_user
now = Time.now.utc
logout_user
- User.first.last_logout_at.should_not be_nil
- User.first.last_logout_at.to_s.should >= now.to_s
- User.first.last_logout_at.to_s.should <= (now+2).to_s
+ User.first.last_logout_at.utc.should_not be_nil
+ User.first.last_logout_at.utc.to_s.should >= now.utc.to_s
+ User.first.last_logout_at.utc.to_s.should <= (now.utc+2).to_s
end
it "should log last activity time when logged in" do
login_user
now = Time.now.utc
get :some_action
- User.first.last_activity_at.to_s.should >= now.to_s
- User.first.last_activity_at.to_s.should <= (now+2).to_s
+ User.first.last_activity_at.utc.should >= now.utc
+ User.first.last_activity_at.utc.should <= (now.utc+2)
end
it "should update nothing but activity fields" do

2 comments on commit 8806f9d

Contributor

durran replied Apr 14, 2012

Sorry about that - I ran them in my time zone, but should have switched to something behind utc as well and run them again. Apologies.

Owner

NoamB replied Apr 14, 2012

That's OK, can happen...

I'm worried that I had to use to_s there and it didn't work without, even though using >= and <= and the output looks identical.

Please sign in to comment.