Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixing some specs

  • Loading branch information...
commit 8806f9d0717cc020bfb5625fd1eaabac38f1c99c 1 parent ba30e86
@NoamB authored
View
1  Rakefile
@@ -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
View
1  spec/rails3/db/migrate/brute_force_protection/20101224223626_add_brute_force_protection_to_users.rb
@@ -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
View
11 spec/rails3/spec/controller_brute_force_protection_spec.rb
@@ -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)
View
14 spec/rails3_mongoid/spec/controller_activity_logging_spec.rb
@@ -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

@durran

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.

@NoamB
Owner

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.
Something went wrong with that request. Please try again.