dbAccessor 0.1.4 → 0.1.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: b880eb3b9ef4c01a57315c4b04b50bf3ca90dd7d
4
- data.tar.gz: 1fc7cca67db5273802dea1010b932e7582c0281c
3
+ metadata.gz: 1c61b012dfc9cccbae90d2061d52e8a4d688890c
4
+ data.tar.gz: 79b90af685032fb41cd27a4908c52a72a1782a32
5
5
  SHA512:
6
- metadata.gz: 6603078e3d289a6a5a02d1a08e879ffbd5a290766b8e90599531df582b3c075f8fa4d399fa8b472af84d5d2554d7aedc960feb241ad018228f12192a7bcfdc94
7
- data.tar.gz: 32a808da4e3bf5fc7dcb4b1aff528dd592c9f45e53b464d1084fdde2619aa546e146dc5d3c024446b0d3537df89824eb0cdbb77e958e211f92e40f3d8f84ec9a
6
+ metadata.gz: 13d1aee432f57aa4cc02c9403341defd8617a9934c0f7e84f2b3c706aa69ab5aa518dd87ece694310e4537762cacde4804753054ba85c0f8ddf1dde1c4b2e89e
7
+ data.tar.gz: 36e9379fdc0c6f6c265e34aa924b40bcd7e893509389c143c00a2590c87de1e27854bac6269d3ad73016aa40f5c4f4bda24061d192ad078c7c7615faf972f39c
@@ -75,9 +75,9 @@ module Db_Accessor
75
75
  attributes = engine_data_columns
76
76
  end
77
77
 
78
+
78
79
  verify_keys(keys,attributes)
79
80
  end
80
-
81
81
  def self.valid_class?(keys,columns,attributes)
82
82
  keys.each do |k|
83
83
  if columns.include?(k)
@@ -96,8 +96,8 @@ module Db_Accessor
96
96
  end
97
97
 
98
98
  def self.valid_attributes_values?(attributes)
99
- string_columns = [:login,:password,:firstname,:lastname,:gender,:email,:api_key,:name,:url]
100
- fixnum_columns = [:user_id,:id]
99
+ string_columns = [:login,:password,:firstname,:lastname,:gender,:email,:api_key,:name,:url,:engine_conf]
100
+ fixnum_columns = [:user_id,:id,:engine_id,:application_id,:customer_id,:item_id,:preference]
101
101
  keys = attributes.keys
102
102
  valid_class?(keys,string_columns,attributes)
103
103
  end
@@ -1,3 +1,3 @@
1
1
  module DbAccessor
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
data/spec/updater_spec.rb CHANGED
@@ -5,7 +5,7 @@ require 'uuid'
5
5
  describe DbAccessor::Updater do
6
6
 
7
7
  nb = rand(50)
8
-
8
+
9
9
  describe ".update_by_id" do
10
10
 
11
11
  context "updates one or many users by id" do
@@ -16,20 +16,23 @@ describe DbAccessor::Updater do
16
16
  context "updates one or many applications by id" do
17
17
  param = {model_name: "Application",attributes: {15 => {api_key: UUID.new.generate}} }
18
18
  it {expect((DbAccessor::Updater.update_by_id(param))[:code]).to eq 200 }
19
+
20
+ param = {model_name: "Engine",attributes: {5 => {engine_conf: {name: 'name', similarity_metric: 'similarity_metric',reco_algo: 'reco_algo',neighborhood: 'neighborhood'}.to_json} } }
21
+ it {expect((DbAccessor::Updater.update_by_id(param))[:code]).to eq 200 }
19
22
  end
20
23
 
21
24
  context "when attributes format is not correct" do
22
25
  param = {model_name: "Application",attributes: { 'c' => { name: "apache"},2 => {name: "site du zero"}} }
23
26
  it {expect((DbAccessor::Updater.update_by_id(param))[:code]).to eq 400 }
24
27
 
25
- param[:attributes] = { 3 => { na: "apache"},2 => {name: "site du zero"}}
28
+ param[:attributes] = { 3 => { na: "apache"},2 => {name: "site du zero"}}
26
29
  it {expect((DbAccessor::Updater.update_by_id(param))[:code]).to eq 400 }
27
30
 
28
31
  param[:attributes] = { 3 => { name: 1},2 => {name: "site du zero"}}
29
32
  it {expect((DbAccessor::Updater.update_by_id(param))[:code]).to eq 400 }
30
33
 
31
- param[:attributes] = { 3 => nil,2 => {name: "site du zero"}}
32
34
  it {expect((DbAccessor::Updater.update_by_id(param))[:code]).to eq 400 }
35
+ param[:attributes] = { 3 => nil,2 => {name: "site du zero"}}
33
36
 
34
37
  param[:attributes] = { 3 => " ",2 => {name: "site du zero"}}
35
38
  it {expect((DbAccessor::Updater.update_by_id(param))[:code]).to eq 400 }
@@ -45,35 +48,36 @@ describe DbAccessor::Updater do
45
48
  end
46
49
 
47
50
  context "when the object is not found" do
48
- param = {model_name: "User",attributes: { 10000 => { login: "fabi"}} }
51
+ param = {model_name: "User",attributes: { 10000 => { login: "fabi"}} }
49
52
  it {expect((DbAccessor::Updater.update_by_id(param))[:code]).to eq 400 }
50
53
  end
51
54
 
52
- context "when the passed parameter is nil" do
55
+ context "when the passed parameter is nil" do
53
56
  it {expect((DbAccessor::Updater.update_by_id(nil))[:code]).to eq 400 }
54
57
  end
55
58
 
56
- context "when attributes to update are empty" do
59
+ context "when attributes to update are empty" do
57
60
  it {expect((DbAccessor::Updater.update_by_id(model_name: "User",attributes: {}))[:code]).to eq 400 }
58
61
  end
59
62
 
60
- context "when the model name is incorrect" do
63
+ context "when the model name is incorrect" do
61
64
  it {expect((DbAccessor::Updater.update_by_id(model_name: "Us",attributes: {}))[:code]).to eq 400 }
62
65
  end
63
66
 
64
- context "when the attributes are not correct" do
67
+ context "when the attributes are not correct" do
65
68
  it {expect((DbAccessor::Updater.update_by_id(model_name: "Application",attributes: "coucou"))[:code]).to eq 400 }
66
69
  end
67
70
 
68
71
  end
69
72
 
70
-
73
+
71
74
 
72
75
  describe ".update_all_objects" do
73
76
  parameter={model_name: "User", attributes: {password: "passe#{nb}"}}
74
- context "when it updates all model objects" do
77
+
78
+ context "when it updates all model objects" do
75
79
  it {expect((DbAccessor::Updater.update_all_objects(parameter))[:code]).to eq 200 }
76
- end
80
+ end
77
81
 
78
82
  context "when all model objects that satisfy the condition are updated" do
79
83
  condition={login: 'modou'}
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
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - fabira
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-03 00:00:00.000000000 Z
11
+ date: 2014-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler