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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aa22bc43651260b9bf9d759aa142da59a9fa4fd1
4
- data.tar.gz: 754b6ce65db9e047bee072c3bb8ee7bf25e80692
3
+ metadata.gz: 273722f73520c74ccc345efd72915f9253d47906
4
+ data.tar.gz: da7149b36435bf62be3efc98e10339acb118b5d5
5
5
  SHA512:
6
- metadata.gz: 9e1577953efccd53c0c0122168b226710ca7b179a0c988d9bac85d3ffa87ebc9d936f9f58e7350042a509da824c391e510bb508e94b4b3c268c9aaa0ead9b06a
7
- data.tar.gz: 68c73b80c685a3b2a3e7d0fac80f43c726d78dea0bbed58d5d4a8b7cab80006dd4f55934b6dc9fed80977488a41ff98e356168267a0a32704fb92efce1f1710b
6
+ metadata.gz: 160acc3f4ca22bb8a51dc217988604ea13ff69f52c9c9cdd0c18b8be9c93be3885882eab8ea38b531b85fe930a78dbe1f20b25c2731b88eb0f7df5afbd939aed
7
+ data.tar.gz: da5563c484b3b3b20b48700690903140904bfd792d1cc936ad1b80d9b5d2083767c180b197cc14c9671d9ed3d68f4ce9de6ff2b638a36966c99cf8e8330c7164
@@ -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
- [ SIGN_IN, SIGN_UP, TOUCHED_CURRENT_USER, TOUCHED_EMAIL_USER ]
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
@@ -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
@@ -1,4 +1,4 @@
1
1
  module Socialmux
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
4
4
 
@@ -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.5
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-08 00:00:00.000000000 Z
11
+ date: 2013-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler