restpack_account_service 0.0.4 → 0.0.5
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/Rakefile +1 -1
- data/db/migrate/{20130919115210_create_accounts.rb → 20130919115211_create_accounts.rb} +1 -1
- data/lib/restpack_account_service.rb +1 -1
- data/lib/restpack_account_service/commands/account/create.rb +9 -16
- data/lib/restpack_account_service/commands/account/get.rb +5 -17
- data/lib/restpack_account_service/models/account.rb +2 -2
- data/lib/restpack_account_service/serializers/account.rb +2 -2
- data/lib/restpack_account_service/version.rb +1 -1
- data/spec/commands/account/create_spec.rb +4 -29
- data/spec/commands/account/get_spec.rb +2 -2
- data/spec/factories/account.rb +1 -1
- data/spec/factories/api_account.rb +9 -0
- data/spec/models/account_spec.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 13434ac13f103eac8e0116648e6be345f052d383
|
4
|
+
data.tar.gz: 2f10acdedac8d08cd54d507f423c7e113b05edbe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17e69aec099da18f9d332bc35ae32ff50f9bc3ed4715a63ed8a3c3a9c75c230ff72e7054be648e73a948f6e5bb71dd2fc7755e0095f74a68ad2fa5e8800be8be
|
7
|
+
data.tar.gz: bfdcd34bdcdc07ce1b132509e9df41587f9fef41242404bf193d48bea3e9f4d2b300353bbbf39fdd59c4ed44400ef662b13b79fe4b433ae253c3093d53dddae1
|
data/Rakefile
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
require
|
1
|
+
require 'restpack_gem'
|
2
2
|
RestPack::Gem::Tasks.load_service_tasks
|
@@ -1,6 +1,6 @@
|
|
1
1
|
class CreateAccounts < ActiveRecord::Migration
|
2
2
|
def change
|
3
|
-
create_table :
|
3
|
+
create_table :restpack_account_accounts do |t|
|
4
4
|
t.integer :created_by, :null => false
|
5
5
|
t.integer :application_id, :null => false
|
6
6
|
t.string :name, :null => false, :limit => 256
|
@@ -1,2 +1,2 @@
|
|
1
1
|
require 'restpack_service'
|
2
|
-
RestPack::Service::Loader.load '
|
2
|
+
RestPack::Service::Loader.load 'restpack_account_service', 'Accounts'
|
@@ -1,22 +1,15 @@
|
|
1
|
-
module
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
string :name
|
11
|
-
end
|
1
|
+
module Commands::Accounts::Account
|
2
|
+
class Create < RestPack::Service::Commands::Create
|
3
|
+
required do
|
4
|
+
array :accounts do
|
5
|
+
hash do
|
6
|
+
required do
|
7
|
+
integer :application_id
|
8
|
+
integer :created_by
|
9
|
+
string :name
|
12
10
|
end
|
13
11
|
end
|
14
12
|
end
|
15
|
-
|
16
|
-
def execute
|
17
|
-
accounts = Models::Account.create!(inputs[:accounts])
|
18
|
-
Serializers::Account.serialize(accounts)
|
19
|
-
end
|
20
13
|
end
|
21
14
|
end
|
22
15
|
end
|
@@ -1,20 +1,8 @@
|
|
1
|
-
module
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
integer :application_id
|
7
|
-
end
|
8
|
-
|
9
|
-
def execute
|
10
|
-
result = Serializers::Account.resource(inputs)
|
11
|
-
|
12
|
-
if result[:accounts].empty?
|
13
|
-
status :not_found
|
14
|
-
else
|
15
|
-
result
|
16
|
-
end
|
17
|
-
end
|
1
|
+
module Commands::Accounts::Account
|
2
|
+
class Get < RestPack::Service::Commands::Get
|
3
|
+
required do
|
4
|
+
integer :id
|
5
|
+
integer :application_id
|
18
6
|
end
|
19
7
|
end
|
20
8
|
end
|
@@ -1,6 +1,6 @@
|
|
1
|
-
module
|
1
|
+
module Models::Accounts
|
2
2
|
class Account < ActiveRecord::Base
|
3
|
-
self.table_name = :
|
3
|
+
self.table_name = :restpack_account_accounts
|
4
4
|
|
5
5
|
attr_accessible :application_id, :created_by, :name
|
6
6
|
validates_presence_of :application_id, :created_by, :name
|
@@ -1,8 +1,8 @@
|
|
1
|
-
module
|
1
|
+
module Serializers::Accounts
|
2
2
|
class Account
|
3
3
|
include RestPack::Serializer
|
4
4
|
|
5
|
-
self.model_class = Models::Account
|
5
|
+
self.model_class = Models::Accounts::Account
|
6
6
|
self.key = :accounts
|
7
7
|
|
8
8
|
attributes :id, :application_id, :created_by, :name, :href
|
@@ -1,32 +1,7 @@
|
|
1
|
-
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Commands::Account::Create do
|
4
|
-
|
5
|
-
# is_required :created_by, :name
|
3
|
+
describe Commands::Accounts::Account::Create do
|
4
|
+
it_acts_as_create_command(:accounts, :account)
|
6
5
|
|
7
|
-
|
8
|
-
let(:response) { subject.class.run(params) }
|
9
|
-
|
10
|
-
context 'with valid params' do
|
11
|
-
let(:account) { {
|
12
|
-
application_id: 111,
|
13
|
-
created_by: 234,
|
14
|
-
name: 'My New Group'
|
15
|
-
} }
|
16
|
-
let(:params) { {
|
17
|
-
accounts: [account]
|
18
|
-
} }
|
19
|
-
|
20
|
-
it 'returns the newly created account' do
|
21
|
-
response.success?.should == true
|
22
|
-
|
23
|
-
accounts = response.result[:accounts]
|
24
|
-
accounts.length.should == 1
|
25
|
-
|
26
|
-
accounts.first[:application_id].should == 111
|
27
|
-
accounts.first[:created_by].should == 234
|
28
|
-
accounts.first[:name].should == "My New Group"
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
6
|
+
pending 'validate command inputs'
|
32
7
|
end
|
data/spec/factories/account.rb
CHANGED
data/spec/models/account_spec.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: restpack_account_service
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gavin Joyce
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: restpack_service
|
@@ -136,7 +136,7 @@ files:
|
|
136
136
|
- README.md
|
137
137
|
- Rakefile
|
138
138
|
- config/database.yml
|
139
|
-
- db/migrate/
|
139
|
+
- db/migrate/20130919115211_create_accounts.rb
|
140
140
|
- lib/restpack_account_service.rb
|
141
141
|
- lib/restpack_account_service/commands/account/create.rb
|
142
142
|
- lib/restpack_account_service/commands/account/get.rb
|
@@ -150,6 +150,7 @@ files:
|
|
150
150
|
- spec/commands/account/create_spec.rb
|
151
151
|
- spec/commands/account/get_spec.rb
|
152
152
|
- spec/factories/account.rb
|
153
|
+
- spec/factories/api_account.rb
|
153
154
|
- spec/models/account_spec.rb
|
154
155
|
- spec/spec_helper.rb
|
155
156
|
homepage: https://github.com/RestPack
|
@@ -180,5 +181,6 @@ test_files:
|
|
180
181
|
- spec/commands/account/create_spec.rb
|
181
182
|
- spec/commands/account/get_spec.rb
|
182
183
|
- spec/factories/account.rb
|
184
|
+
- spec/factories/api_account.rb
|
183
185
|
- spec/models/account_spec.rb
|
184
186
|
- spec/spec_helper.rb
|