socialmux 0.0.5 → 0.0.6
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/socialmux/event.rb +8 -1
- data/lib/socialmux/strategy.rb +8 -0
- data/lib/socialmux/version.rb +1 -1
- data/spec/lib/strategy_spec.rb +14 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 273722f73520c74ccc345efd72915f9253d47906
|
|
4
|
+
data.tar.gz: da7149b36435bf62be3efc98e10339acb118b5d5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 160acc3f4ca22bb8a51dc217988604ea13ff69f52c9c9cdd0c18b8be9c93be3885882eab8ea38b531b85fe930a78dbe1f20b25c2731b88eb0f7df5afbd939aed
|
|
7
|
+
data.tar.gz: da5563c484b3b3b20b48700690903140904bfd792d1cc936ad1b80d9b5d2083767c180b197cc14c9671d9ed3d68f4ce9de6ff2b638a36966c99cf8e8330c7164
|
data/lib/socialmux/event.rb
CHANGED
|
@@ -4,9 +4,16 @@ module Socialmux
|
|
|
4
4
|
SIGN_UP = :sign_up
|
|
5
5
|
TOUCHED_CURRENT_USER = :updated_current_user
|
|
6
6
|
TOUCHED_EMAIL_USER = :updated_email_user
|
|
7
|
+
AUTHENTICATION_ALREADY_TAKEN = :authentication_already_taken
|
|
7
8
|
|
|
8
9
|
def self.all
|
|
9
|
-
[
|
|
10
|
+
[
|
|
11
|
+
SIGN_IN,
|
|
12
|
+
SIGN_UP,
|
|
13
|
+
TOUCHED_CURRENT_USER,
|
|
14
|
+
TOUCHED_EMAIL_USER,
|
|
15
|
+
AUTHENTICATION_ALREADY_TAKEN
|
|
16
|
+
]
|
|
10
17
|
end
|
|
11
18
|
end
|
|
12
19
|
end
|
data/lib/socialmux/strategy.rb
CHANGED
|
@@ -20,6 +20,7 @@ module Socialmux
|
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
def result
|
|
23
|
+
authentication_already_taken ||
|
|
23
24
|
returning_user ||
|
|
24
25
|
augmented_current_user ||
|
|
25
26
|
augmented_user_with_same_email ||
|
|
@@ -32,6 +33,13 @@ module Socialmux
|
|
|
32
33
|
|
|
33
34
|
private
|
|
34
35
|
|
|
36
|
+
def authentication_already_taken
|
|
37
|
+
user = adapter.find_user_with_authentication(data)
|
|
38
|
+
if current_user && user && current_user != user
|
|
39
|
+
Result.new(nil, Event::AUTHENTICATION_ALREADY_TAKEN)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
35
43
|
def returning_user
|
|
36
44
|
user = adapter.find_user_with_authentication(data)
|
|
37
45
|
Result.new(user, Event::SIGN_IN) if user
|
data/lib/socialmux/version.rb
CHANGED
data/spec/lib/strategy_spec.rb
CHANGED
|
@@ -30,7 +30,21 @@ module Socialmux
|
|
|
30
30
|
strategy.stubs(:augment_user)
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
+
context 'previous authentication is found, but linked to a user different than the one currently signed in' do
|
|
34
|
+
let(:current_user) { user }
|
|
35
|
+
let(:another_user) { stub('User') }
|
|
36
|
+
|
|
37
|
+
before do
|
|
38
|
+
adapter.stubs(:find_user_with_authentication).with(mapper).returns(another_user)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
its(:user) { should be_nil }
|
|
42
|
+
its(:event) { should eq Event::AUTHENTICATION_ALREADY_TAKEN }
|
|
43
|
+
end
|
|
44
|
+
|
|
33
45
|
context "previous authentication is found" do
|
|
46
|
+
let(:current_user) { nil }
|
|
47
|
+
|
|
34
48
|
before do
|
|
35
49
|
adapter.stubs(:find_user_with_authentication).with(mapper).returns(user)
|
|
36
50
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: socialmux
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Stefano Verna
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2013-
|
|
11
|
+
date: 2013-12-05 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|