woopy 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,6 +8,7 @@ require 'woopy/client'
8
8
  require 'woopy/resource'
9
9
  require 'woopy/user'
10
10
  require 'woopy/account'
11
+ require 'woopy/role'
11
12
  require 'woopy/employment'
12
13
  require 'woopy/ownership'
13
14
 
@@ -17,5 +17,10 @@ module Woopy
17
17
 
18
18
  Employment.new(employment_json, true)
19
19
  end
20
+
21
+ def grant_role(user, roles)
22
+ false unless roles.class == Array
23
+ Account.put("#{self.id}/users/#{user.id}/update_roles", { roles: roles })
24
+ end
20
25
  end
21
- end
26
+ end
@@ -0,0 +1,8 @@
1
+ module Woopy
2
+ class Role < Resource
3
+ def initialize(attributes = {}, persisted = false)
4
+ self.class.site = Resource.site + "accounts/:account_id/users/:user_id/"
5
+ super(attributes, persisted)
6
+ end
7
+ end
8
+ end
@@ -1,3 +1,3 @@
1
1
  module Woopy
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
@@ -44,6 +44,10 @@ def employment_attributes
44
44
  { account_id: 1, user_id: 1 }
45
45
  end
46
46
 
47
+ def roles_attributes
48
+ {roles: ["role1", "role2"] }
49
+ end
50
+
47
51
  def ownership_response
48
52
  { ownership: ownership_attributes.merge(id: 1) }.to_json
49
53
  end
@@ -6,13 +6,15 @@ describe Woopy::Account do
6
6
  @token = 'foo'
7
7
  Woopy(token: @token)
8
8
  ActiveResource::HttpMock.respond_to do |mock|
9
- mock.post( '/services/v1/accounts.json', request_headers(@token), account_response )
10
- mock.post( '/services/v1/users.json', request_headers(@token), user_response )
11
- mock.post( '/services/v1/ownerships.json', request_headers(@token), ownership_response )
9
+ mock.post( '/services/v1/accounts.json', request_headers(@token), account_response )
10
+ mock.post( '/services/v1/users.json', request_headers(@token), user_response )
11
+ mock.post( '/services/v1/ownerships.json', request_headers(@token), ownership_response )
12
12
 
13
13
  mock.get( '/services/v1/accounts/1/users/1/employment.json', accept_request_headers(@token), employment_response )
14
14
  mock.post( '/services/v1/accounts/1/employments.json', request_headers(@token), employment_response )
15
15
  mock.delete( '/services/v1/accounts/1/employments/1.json', accept_request_headers(@token), employment_response )
16
+
17
+ mock.put( "/services/v1/accounts/1/users/1/update_roles.json?#{ roles_attributes.to_query }", request_headers(@token), :ok )
16
18
  end
17
19
  end
18
20
 
@@ -64,5 +66,12 @@ describe Woopy::Account do
64
66
  it { should be_persisted }
65
67
  its(:user_id) { should == @user.id }
66
68
  end
69
+
70
+ describe "#grant_role" do
71
+ subject { @account.grant_role(@user, ["role1", "role2"]) }
72
+
73
+ it { should be_true }
74
+ end
75
+
67
76
  end
68
77
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: woopy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-21 00:00:00.000000000 Z
12
+ date: 2012-03-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
- requirement: &70327883433640 !ruby/object:Gem::Requirement
16
+ requirement: &70136584535640 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70327883433640
24
+ version_requirements: *70136584535640
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &70327883432480 !ruby/object:Gem::Requirement
27
+ requirement: &70136584535140 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '2.8'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70327883432480
35
+ version_requirements: *70136584535140
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: json
38
- requirement: &70327883431080 !ruby/object:Gem::Requirement
38
+ requirement: &70136584534720 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70327883431080
46
+ version_requirements: *70136584534720
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: gem-release
49
- requirement: &70327883280420 !ruby/object:Gem::Requirement
49
+ requirement: &70136584534260 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70327883280420
57
+ version_requirements: *70136584534260
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: activeresource
60
- requirement: &70327883278720 !ruby/object:Gem::Requirement
60
+ requirement: &70136584533760 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: '3.1'
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *70327883278720
68
+ version_requirements: *70136584533760
69
69
  description: Wraps the Woople API as ActiveResources
70
70
  email:
71
71
  - developers@bigbangtechnology.com
@@ -85,6 +85,7 @@ files:
85
85
  - lib/woopy/employment.rb
86
86
  - lib/woopy/ownership.rb
87
87
  - lib/woopy/resource.rb
88
+ - lib/woopy/role.rb
88
89
  - lib/woopy/user.rb
89
90
  - lib/woopy/version.rb
90
91
  - spec/spec_helper.rb
@@ -104,21 +105,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
104
105
  - - ! '>='
105
106
  - !ruby/object:Gem::Version
106
107
  version: '0'
107
- segments:
108
- - 0
109
- hash: -1435565781307241770
110
108
  required_rubygems_version: !ruby/object:Gem::Requirement
111
109
  none: false
112
110
  requirements:
113
111
  - - ! '>='
114
112
  - !ruby/object:Gem::Version
115
113
  version: '0'
116
- segments:
117
- - 0
118
- hash: -1435565781307241770
119
114
  requirements: []
120
115
  rubyforge_project: woopy
121
- rubygems_version: 1.8.10
116
+ rubygems_version: 1.8.17
122
117
  signing_key:
123
118
  specification_version: 3
124
119
  summary: Woople API Wrapper