dbAccessor 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dbAccessor/base.rb +1 -1
- data/lib/dbAccessor/reader/reader.rb +1 -2
- data/lib/dbAccessor/version.rb +1 -1
- data/lib/dbAccessor/writer/writer.rb +1 -1
- data/spec/feed/dbTest/migration/create_table_engines.rb +2 -2
- data/spec/feed/dbTest/model/application.rb +2 -2
- data/spec/feed/dbTest/model/engine.rb +1 -1
- data/spec/feed/dbTest/model/user.rb +2 -2
- data/spec/updater_spec.rb +7 -2
- data/spec/writer_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: 4a41358d7b31fa18301d319fb3c36551ca9aff86
|
4
|
+
data.tar.gz: f71da5be6755d7d1b56a34713530c958a3a501ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a681cbec809a0b117631dad40ca02201f6d3c6244b2fcc5e84436f6670a0b59262581bf3ecdde9cf644735f294a3a1b5678b36c1bc672b7b4e587b5621c7e05
|
7
|
+
data.tar.gz: 1ba240a0cc60456647e82bba6da60c4b33cde3c7f55759748a7eaf467dd7af6b36f9904f80ea15bb3e654078180c4a0f0c623c91f6a170c94d809d46fb4c6276
|
data/lib/dbAccessor/base.rb
CHANGED
@@ -64,7 +64,7 @@ module Db_Accessor
|
|
64
64
|
end
|
65
65
|
|
66
66
|
def self.valid_object_columns?(model_name,content)
|
67
|
-
engine_columns = [:id,:name,:
|
67
|
+
engine_columns = [:id,:name,:application_id]
|
68
68
|
engine_data_columns = [:id,:customer_id,:item_id,:preference,:engine_id]
|
69
69
|
action_columns = [:id,:name,:score]
|
70
70
|
assignment_columns = [:id,:engine_id,:action_id]
|
@@ -34,8 +34,7 @@ class DbAccessor::Reader < Db_Accessor::Base
|
|
34
34
|
waited_keys = [:model_name,:identifiers]
|
35
35
|
if validate(given_param,waited_keys) && validate_id(given_param[:identifiers])
|
36
36
|
model_name = get_model_name(given_param)
|
37
|
-
result = model_name.where(deleted: false).where(id: given_param[:identifiers])
|
38
|
-
p result
|
37
|
+
result = model_name.where(deleted: false).where(id: given_param[:identifiers])
|
39
38
|
result.nil? ? return_response(404,"Not found") : return_response(200,result)
|
40
39
|
else
|
41
40
|
return_response(404,"Not found")
|
data/lib/dbAccessor/version.rb
CHANGED
@@ -37,7 +37,7 @@ private ######################################################################
|
|
37
37
|
elsif model_name == 'Application'
|
38
38
|
content[:name].is_a?(String) && content[:api_key].is_a?(String) && content[:url].is_a?(String)
|
39
39
|
elsif model_name == 'Engine'
|
40
|
-
content[:name].is_a?(String) && content[:
|
40
|
+
content[:name].is_a?(String) && content[:application_id].is_a?(Fixnum)
|
41
41
|
else
|
42
42
|
false
|
43
43
|
end
|
@@ -1,8 +1,7 @@
|
|
1
1
|
class CreateEngines < ActiveRecord::Migration
|
2
2
|
def self.up
|
3
3
|
create_table :engines do |e|
|
4
|
-
e.string :name
|
5
|
-
e.string :action_based
|
4
|
+
e.string :name
|
6
5
|
e.integer :application_id
|
7
6
|
e.timestamps
|
8
7
|
end
|
@@ -15,4 +14,5 @@ class CreateEngines < ActiveRecord::Migration
|
|
15
14
|
|
16
15
|
end
|
17
16
|
|
17
|
+
CreateEngines.down
|
18
18
|
CreateEngines.up
|
data/spec/updater_spec.rb
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
require_relative 'spec_helper'
|
2
2
|
require 'redis'
|
3
|
+
require 'uuid'
|
3
4
|
|
4
5
|
describe DbAccessor::Updater do
|
6
|
+
|
7
|
+
nb = rand(50)
|
5
8
|
|
6
9
|
describe ".update_by_id" do
|
7
10
|
|
@@ -11,7 +14,7 @@ describe DbAccessor::Updater do
|
|
11
14
|
end
|
12
15
|
|
13
16
|
context "updates one or many applications by id" do
|
14
|
-
param = {model_name: "Application",attributes: {
|
17
|
+
param = {model_name: "Application",attributes: {15 => {api_key: UUID.new.generate}} }
|
15
18
|
it {expect((DbAccessor::Updater.update_by_id(param))[:code]).to eq 200 }
|
16
19
|
end
|
17
20
|
|
@@ -64,8 +67,10 @@ describe DbAccessor::Updater do
|
|
64
67
|
|
65
68
|
end
|
66
69
|
|
70
|
+
|
71
|
+
|
67
72
|
describe ".update_all_objects" do
|
68
|
-
parameter={model_name: "User", attributes: {password:
|
73
|
+
parameter={model_name: "User", attributes: {password: "passe#{nb}"}}
|
69
74
|
context "when it updates all model objects" do
|
70
75
|
it {expect((DbAccessor::Updater.update_all_objects(parameter))[:code]).to eq 200 }
|
71
76
|
end
|
data/spec/writer_spec.rb
CHANGED
@@ -6,11 +6,11 @@ describe DbAccessor::Writer do
|
|
6
6
|
nb = rand(1000)
|
7
7
|
api_key = UUID.new.generate
|
8
8
|
|
9
|
-
let(:user) { {model_name: 'User',content: {login: '
|
9
|
+
let(:user) { {model_name: 'User',content: {login: 'diakhoumpa'+nb.to_s,password: 'passeraa',firstname: 'Ndeye Fatou', lastname: 'Dieng',email: 'diakhouumpa'+nb.to_s+'@gmail.com',gender: 'M'}} }
|
10
10
|
|
11
|
-
let(:app) { {model_name: 'Application',content: {name: '
|
11
|
+
let(:app) { {model_name: 'Application',content: {name: 'desert'+nb.to_s,api_key: api_key,url: 'http://www.desert'+nb.to_s+'.com',user_id: 2}} }
|
12
12
|
|
13
|
-
let(:engine) { {model_name: 'Engine',content: {name: '
|
13
|
+
let(:engine) { {model_name: 'Engine',content: {name: 'engine'+nb.to_s,application_id: 2}} }
|
14
14
|
|
15
15
|
describe".write_object" do
|
16
16
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dbAccessor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- fabira
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|