restpack_activity_service 0.0.5 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/restpack_activity_service.rb +5 -1
- data/lib/restpack_activity_service/api/{activity_api.rb → activity.rb} +7 -7
- data/lib/restpack_activity_service/services.rb +1 -1
- data/lib/restpack_activity_service/services/activity/create.rb +3 -3
- data/lib/restpack_activity_service/services/activity/destroy.rb +2 -2
- data/lib/restpack_activity_service/services/activity/get.rb +3 -3
- data/lib/restpack_activity_service/services/activity/list.rb +3 -3
- data/lib/restpack_activity_service/services/activity/update.rb +1 -1
- data/lib/restpack_activity_service/version.rb +1 -1
- data/spec/factories/activity_factory.rb +1 -1
- data/spec/services/create_spec.rb +1 -1
- data/spec/services/destroy_spec.rb +2 -2
- data/spec/services/get_spec.rb +1 -1
- data/spec/services/list_spec.rb +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f1c0a9d1afe7536bc41a7094a5403a15aa68d67
|
4
|
+
data.tar.gz: dfed5e4025f88cf0174c439f56c6341a3399b530
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 47d68d0783d43340d351fefe90df707dff3881a1d504f47c208dc315982b1bd1ebd3850edd9cbf9bc77e7df56f7ae5a9e5287d2fa8082ee6586d860f2753d57b
|
7
|
+
data.tar.gz: 6d1ccc2c5e9fe1ab100ddc57a2abce348cbb1e5cc027aa564526cae8cdc3f44e8c1e69fa2e6182987d6b2a72c8aca4f0e4294133c641d0f386afa889cf7e6ace
|
@@ -11,4 +11,8 @@ require "restpack_activity_service/serializers/activity_serializer"
|
|
11
11
|
require "restpack_activity_service/services"
|
12
12
|
require "restpack_activity_service/tasks"
|
13
13
|
|
14
|
-
require "restpack_activity_service/api/
|
14
|
+
require "restpack_activity_service/api/activity"
|
15
|
+
|
16
|
+
Models = RestPack::Activity::Service::Models
|
17
|
+
Commands = RestPack::Activity::Service::Commands
|
18
|
+
Serializers = RestPack::Activity::Service::Serializers
|
@@ -1,25 +1,25 @@
|
|
1
1
|
require 'sinatra'
|
2
2
|
|
3
|
-
module RestPack
|
4
|
-
class
|
3
|
+
module RestPack::Activity::Service::Api
|
4
|
+
class Activity < Sinatra::Base
|
5
5
|
get "/.json" do
|
6
|
-
render
|
6
|
+
render Commands::Activity::List.run(params, application_params)
|
7
7
|
end
|
8
8
|
|
9
9
|
get "/:id.json" do
|
10
|
-
render
|
10
|
+
render Commands::Activity::Get.run(params, application_params)
|
11
11
|
end
|
12
12
|
|
13
13
|
post "/.json" do
|
14
|
-
render
|
14
|
+
render Commands::Activity::Create.run(params, application_params)
|
15
15
|
end
|
16
16
|
|
17
17
|
put "/:id.json" do
|
18
|
-
render
|
18
|
+
render Commands::Activity::Update.run(params, application_params)
|
19
19
|
end
|
20
20
|
|
21
21
|
delete "/:id.json" do
|
22
|
-
render
|
22
|
+
render Commands::Activity::Destroy.run(params, application_params)
|
23
23
|
end
|
24
24
|
|
25
25
|
private
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module RestPack::
|
1
|
+
module RestPack::Activity::Service::Commands::Activity
|
2
2
|
class Create < RestPack::Service::Command
|
3
3
|
required do
|
4
4
|
integer :application_id
|
@@ -33,8 +33,8 @@ module RestPack::Services::Activity
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def execute
|
36
|
-
activity =
|
37
|
-
|
36
|
+
activity = Models::Activity.create(inputs)
|
37
|
+
Serializers::ActivitySerializer.as_json(activity)
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module RestPack::
|
1
|
+
module RestPack::Activity::Service::Commands::Activity
|
2
2
|
class Destroy < RestPack::Service::Command
|
3
3
|
required do
|
4
4
|
integer :id
|
@@ -6,7 +6,7 @@ module RestPack::Services::Activity
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def execute
|
9
|
-
activity =
|
9
|
+
activity = Models::Activity.find_by_id_and_application_id(
|
10
10
|
inputs[:id],
|
11
11
|
inputs[:application_id]
|
12
12
|
)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module RestPack::
|
1
|
+
module RestPack::Activity::Service::Commands::Activity
|
2
2
|
class Get < RestPack::Service::Command
|
3
3
|
required do
|
4
4
|
integer :id
|
@@ -6,13 +6,13 @@ module RestPack::Services::Activity
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def execute
|
9
|
-
activity =
|
9
|
+
activity = Models::Activity.find_by_id_and_application_id(
|
10
10
|
inputs[:id],
|
11
11
|
inputs[:application_id]
|
12
12
|
)
|
13
13
|
|
14
14
|
if activity
|
15
|
-
|
15
|
+
Serializers::ActivitySerializer.as_json(activity)
|
16
16
|
else
|
17
17
|
status :not_found
|
18
18
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module RestPack::
|
1
|
+
module RestPack::Activity::Service::Commands::Activity
|
2
2
|
class List < RestPack::Service::Command
|
3
3
|
required do
|
4
4
|
integer :application_id
|
@@ -14,7 +14,7 @@ module RestPack::Services::Activity
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def execute
|
17
|
-
scope =
|
17
|
+
scope = Models::Activity.all
|
18
18
|
scope = scope.where(application_id: application_id)
|
19
19
|
|
20
20
|
scope = scope.where(user_id: user_id) if user_id
|
@@ -22,7 +22,7 @@ module RestPack::Services::Activity
|
|
22
22
|
scope = scope.any_tags_csv(access, :access) if access
|
23
23
|
scope = scope.search(query) if query
|
24
24
|
|
25
|
-
|
25
|
+
Serializers::ActivitySerializer.resource(inputs, scope)
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require_relative '../spec_helper'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe Commands::Activity::Destroy do
|
4
4
|
is_required :id, :application_id
|
5
5
|
|
6
6
|
let(:response) { subject.class.run(params) }
|
@@ -19,7 +19,7 @@ describe RestPack::Services::Activity::Destroy do
|
|
19
19
|
it 'deletes the activity' do
|
20
20
|
response.success?.should == true
|
21
21
|
response.result.should == {}
|
22
|
-
|
22
|
+
Commands::Activity::Get.run(params).status.should == :not_found
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
data/spec/services/get_spec.rb
CHANGED
data/spec/services/list_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require_relative '../spec_helper'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe Commands::Activity::List do
|
4
4
|
is_required :application_id
|
5
5
|
is_optional :user_id, :page, :page_size, :tags, :access, :query
|
6
6
|
|
@@ -46,7 +46,7 @@ describe RestPack::Services::Activity::List do
|
|
46
46
|
context 'valid' do
|
47
47
|
let(:params) { { application_id: 100 } }
|
48
48
|
it 'retuns activities' do
|
49
|
-
response.result[:meta][:activities][:count].should ==
|
49
|
+
response.result[:meta][:activities][:count].should == Models::Activity.count
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
@@ -63,7 +63,7 @@ describe RestPack::Services::Activity::List do
|
|
63
63
|
let(:params) { { application_id: 100, user_id: 200 }}
|
64
64
|
|
65
65
|
it 'returns activities' do
|
66
|
-
response.result[:meta][:activities][:count].should ==
|
66
|
+
response.result[:meta][:activities][:count].should == Models::Activity.count
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: restpack_activity_service
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gavin Joyce
|
@@ -166,7 +166,7 @@ files:
|
|
166
166
|
- config/database.yml
|
167
167
|
- db/migrate/20130630145408_create_activity_table.rb
|
168
168
|
- lib/restpack_activity_service.rb
|
169
|
-
- lib/restpack_activity_service/api/
|
169
|
+
- lib/restpack_activity_service/api/activity.rb
|
170
170
|
- lib/restpack_activity_service/configuration.rb
|
171
171
|
- lib/restpack_activity_service/models/activity.rb
|
172
172
|
- lib/restpack_activity_service/models/base.rb
|