signinable 2.0.13 → 2.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/signinable/model_additions.rb +17 -9
- data/lib/signinable/version.rb +1 -1
- data/spec/dummy/log/test.log +2749 -0
- data/spec/models/user_spec.rb +20 -5
- data/spec/support/utilities.rb +2 -2
- metadata +2 -2
data/spec/models/user_spec.rb
CHANGED
@@ -77,10 +77,18 @@ describe User do
|
|
77
77
|
end
|
78
78
|
|
79
79
|
describe '#signout' do
|
80
|
+
it 'ignores expired signin' do
|
81
|
+
sign_in_user(user, credentials)
|
82
|
+
signin = user.last_signin
|
83
|
+
Timecop.travel(signin.expiration_time) do
|
84
|
+
expect(sign_out_user(user, credentials)).to be_falsey
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
80
88
|
it 'should expire signin' do
|
81
89
|
sign_in_user(user, credentials)
|
82
90
|
signin = user.last_signin
|
83
|
-
sign_out_user(
|
91
|
+
sign_out_user(user, credentials)
|
84
92
|
expect(signin.reload).to be_expired
|
85
93
|
end
|
86
94
|
|
@@ -88,8 +96,7 @@ describe User do
|
|
88
96
|
%i[ip user_agent].each do |c|
|
89
97
|
it "allows signout when #{c} changes" do
|
90
98
|
sign_in_user(user, credentials)
|
91
|
-
|
92
|
-
expect(sign_out_user(signin, credentials)).to be_truthy
|
99
|
+
expect(sign_out_user(user, credentials)).to be_truthy
|
93
100
|
end
|
94
101
|
end
|
95
102
|
end
|
@@ -99,8 +106,7 @@ describe User do
|
|
99
106
|
it "forbids signout when #{c} changes" do
|
100
107
|
allow(described_class).to receive(:signin_restrictions).and_return([c])
|
101
108
|
sign_in_user(user, credentials)
|
102
|
-
|
103
|
-
expect(sign_out_user(signin, other_credentials)).to be_nil
|
109
|
+
expect(sign_out_user(user, other_credentials)).to be_nil
|
104
110
|
end
|
105
111
|
end
|
106
112
|
end
|
@@ -148,10 +154,19 @@ describe User do
|
|
148
154
|
sign_in_user(user, credentials)
|
149
155
|
end
|
150
156
|
|
157
|
+
it 'returns nil if user not found' do
|
158
|
+
allow(described_class).to receive(:find_by).and_return(nil)
|
159
|
+
expect(described_class.authenticate_with_token(user.jwt, *credentials)).to be_nil
|
160
|
+
end
|
161
|
+
|
151
162
|
it 'returns user' do
|
152
163
|
expect(described_class.authenticate_with_token(user.jwt, *credentials)).to eq(user)
|
153
164
|
end
|
154
165
|
|
166
|
+
it 'returns jwt with user' do
|
167
|
+
expect(described_class.authenticate_with_token(user.jwt, *credentials).jwt).to eq(user.jwt)
|
168
|
+
end
|
169
|
+
|
155
170
|
it 'does not update refresh token' do
|
156
171
|
allow(described_class).to receive(:refresh_jwt)
|
157
172
|
described_class.authenticate_with_token(user.jwt, *credentials)
|
data/spec/support/utilities.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: signinable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Novozhenets
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-06-
|
11
|
+
date: 2022-06-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jwt
|