restpack_account_service 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1bc43eb7e8751ef8c97bb4cd50943616524c1e64
4
- data.tar.gz: 072c107cd0b80fd82a9332a5b72e91266f7fa86d
3
+ metadata.gz: 13434ac13f103eac8e0116648e6be345f052d383
4
+ data.tar.gz: 2f10acdedac8d08cd54d507f423c7e113b05edbe
5
5
  SHA512:
6
- metadata.gz: ea2c3eeb8f36290e5a144255010e1ef218ba159f264db54e597dcd8fdb0de46f2b472f342678d5ffe84649ce80bddec0b1355d7e5b52ee9d4335f53923ec128a
7
- data.tar.gz: 94a76cc6f9afdbcbb07961a2ce61f81562d86a639ca6fc944c3ae4dd6f751d89fdf49b7d5c5f1634050164e8e1c9cf7ccca2d83617bda1b3a521b9d036149b69
6
+ metadata.gz: 17e69aec099da18f9d332bc35ae32ff50f9bc3ed4715a63ed8a3c3a9c75c230ff72e7054be648e73a948f6e5bb71dd2fc7755e0095f74a68ad2fa5e8800be8be
7
+ data.tar.gz: bfdcd34bdcdc07ce1b132509e9df41587f9fef41242404bf193d48bea3e9f4d2b300353bbbf39fdd59c4ed44400ef662b13b79fe4b433ae253c3093d53dddae1
data/Rakefile CHANGED
@@ -1,2 +1,2 @@
1
- require "restpack_gem"
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 :restpack_accounts do |t|
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 'account'
2
+ RestPack::Service::Loader.load 'restpack_account_service', 'Accounts'
@@ -1,22 +1,15 @@
1
- module RestPack::Account::Service::Commands
2
- module Account
3
- class Create < RestPack::Service::Command
4
- required do
5
- array :accounts do
6
- hash do
7
- required do
8
- integer :application_id
9
- integer :created_by
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 RestPack::Account::Service::Commands
2
- module Account
3
- class Get < RestPack::Service::Command
4
- required do
5
- integer :id
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 RestPack::Account::Service::Models
1
+ module Models::Accounts
2
2
  class Account < ActiveRecord::Base
3
- self.table_name = :restpack_accounts
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 RestPack::Account::Service::Serializers
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,7 +1,7 @@
1
1
  module RestPack
2
2
  module Account
3
3
  module Service
4
- VERSION = "0.0.4"
4
+ VERSION = "0.0.5"
5
5
  end
6
6
  end
7
7
  end
@@ -1,32 +1,7 @@
1
- require_relative '../../spec_helper'
1
+ require 'spec_helper'
2
2
 
3
- describe Commands::Account::Create do
4
- #TODO: GJ: validate array
5
- # is_required :created_by, :name
3
+ describe Commands::Accounts::Account::Create do
4
+ it_acts_as_create_command(:accounts, :account)
6
5
 
7
- context 'creating an account' do
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
@@ -1,6 +1,6 @@
1
- require_relative '../../spec_helper'
1
+ require 'spec_helper'
2
2
 
3
- describe Commands::Account::Get do
3
+ describe Commands::Accounts::Account::Get do
4
4
  is_required :id, :application_id
5
5
 
6
6
  let(:response) { subject.class.run(params) }
@@ -1,5 +1,5 @@
1
1
  FactoryGirl.define do
2
- factory :account, :class => Models::Account do
2
+ factory :account, :class => Models::Accounts::Account do
3
3
  sequence(:application_id)
4
4
  sequence(:name) {|n| "Account ##{n}" }
5
5
  sequence(:created_by)
@@ -0,0 +1,9 @@
1
+ FactoryGirl.define do
2
+ factory :api_account, class: Hash do
3
+ sequence(:name) {|n| "Account ##{n}" }
4
+ sequence(:application_id)
5
+ sequence(:created_by)
6
+
7
+ initialize_with { attributes }
8
+ end
9
+ end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Models::Account do
3
+ describe Models::Accounts::Account do
4
4
  it { should validate_presence_of(:application_id) }
5
5
  it { should validate_presence_of(:created_by) }
6
6
  it { should validate_presence_of(:name) }
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
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-09-21 00:00:00.000000000 Z
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/20130919115210_create_accounts.rb
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