Sha256: d3152aa967346e0683c4785f2e05879f44cc37aa2a75c2c6e309951028940815

Contents?: true

Size: 935 Bytes

Versions: 26

Compression:

Stored size: 935 Bytes

Contents

require 'spec_helper'

module NotifyUser
  describe UserHash do

    let(:user) { User.create({email: "user@example.com" })}
    let(:user_hash) { NotifyUser::UserHash.create({target: user, type: "NewPostNotification"})}

    describe "check hash" do
      before :each do
        user_hash.save
      end
      
      it "returns true if hash hasn't be used before" do
        NotifyUser::UserHash.confirm_hash(user_hash.token,"NewPostNotification").should eq true
      end

      it "returns false if hash has been used before" do
        user_hash.deactivate
        NotifyUser::UserHash.confirm_hash(user_hash.token,"NewPostNotification").should eq false
      end

      it "deactivates hash setting active to false" do
        user_hash.deactivate
        user_hash.active.should eq false
      end

      it "generates a 44 character hash on create" do
        user_hash.token.length.should eq 44
      end

    end

  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
notify_user-0.1.4 spec/models/notify_user/user_hash_spec.rb
notify_user-0.1.3 spec/models/notify_user/user_hash_spec.rb
notify_user-0.1.2 spec/models/notify_user/user_hash_spec.rb
notify_user-0.1.1 spec/models/notify_user/user_hash_spec.rb
notify_user-0.0.30 spec/models/notify_user/user_hash_spec.rb
notify_user-0.0.29 spec/models/notify_user/user_hash_spec.rb
notify_user-0.0.28 spec/models/notify_user/user_hash_spec.rb
notify_user-0.0.27 spec/models/notify_user/user_hash_spec.rb
notify_user-0.0.26 spec/models/notify_user/user_hash_spec.rb
notify_user-0.0.25 spec/models/notify_user/user_hash_spec.rb
notify_user-0.0.24 spec/models/notify_user/user_hash_spec.rb
notify_user-0.0.23 spec/models/notify_user/user_hash_spec.rb
notify_user-0.0.22 spec/models/notify_user/user_hash_spec.rb
notify_user-0.0.20 spec/models/notify_user/user_hash_spec.rb
notify_user-0.0.19 spec/models/notify_user/user_hash_spec.rb
notify_user-0.0.18 spec/models/notify_user/user_hash_spec.rb
notify_user-0.0.16 spec/models/notify_user/user_hash_spec.rb
notify_user-0.0.15 spec/models/notify_user/user_hash_spec.rb
notify_user-0.0.14 spec/models/notify_user/user_hash_spec.rb
notify_user-0.0.12 spec/models/notify_user/user_hash_spec.rb