insales_api 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,7 @@ require 'digest/md5'
2
2
  module InsalesApi
3
3
  class App
4
4
  cattr_accessor :api_key, :api_host, :api_secret, :api_autologin_path
5
- attr_accessor :shop, :password, :authorized, :auth_token
5
+ attr_reader :authorized, :auth_token, :shop, :password
6
6
 
7
7
  def initialize(shop, password)
8
8
  @authorized = false
@@ -16,7 +16,7 @@ module InsalesApi
16
16
  end
17
17
 
18
18
  def store_auth_token
19
- @auth_token = InsalesApi::Password.create(password, salt)
19
+ @auth_token ||= InsalesApi::Password.create(password, salt)
20
20
  end
21
21
 
22
22
  def salt
@@ -25,7 +25,7 @@ module InsalesApi
25
25
 
26
26
  def authorize token
27
27
  @authorized = false
28
- if self.auth_token == token
28
+ if self.auth_token and self.auth_token == token
29
29
  @authorized = true
30
30
  end
31
31
 
@@ -1,3 +1,3 @@
1
1
  module InsalesApi
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -41,6 +41,9 @@ describe InsalesApi::App do
41
41
  end
42
42
 
43
43
  describe "authorize" do
44
+ before :each do
45
+ app.store_auth_token
46
+ end
44
47
  it "should authorize by valid token" do
45
48
  app.authorize app.auth_token
46
49
  app.should be_authorized
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: insales_api
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - InSales