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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 79af26c2ea9e2dd2159b10d45f1482cfd4940c4c
4
- data.tar.gz: 025fa79b1230afcc6b225f204fd8cfd213299c21
3
+ metadata.gz: 4a41358d7b31fa18301d319fb3c36551ca9aff86
4
+ data.tar.gz: f71da5be6755d7d1b56a34713530c958a3a501ac
5
5
  SHA512:
6
- metadata.gz: 91d866e68e3c0d32cf151b14219ea11f6af318c23fb1d9c35ccc67dd97dc97136febc9eccc4e8520f863bc3d94203dbe90d042801d19c939eab677bc350f3fc5
7
- data.tar.gz: c16f94e505d41b3f6cd48f4741c30a2dd1315a02ffa9a9d711075e648959d3fdf28688fda4ff70c481edffa96ae8b66795342aa986b321107d67b1674bdec329
6
+ metadata.gz: 2a681cbec809a0b117631dad40ca02201f6d3c6244b2fcc5e84436f6670a0b59262581bf3ecdde9cf644735f294a3a1b5678b36c1bc672b7b4e587b5621c7e05
7
+ data.tar.gz: 1ba240a0cc60456647e82bba6da60c4b33cde3c7f55759748a7eaf467dd7af6b36f9904f80ea15bb3e654078180c4a0f0c623c91f6a170c94d809d46fb4c6276
@@ -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,:action_based,:application_id]
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")
@@ -1,3 +1,3 @@
1
1
  module DbAccessor
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -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[:action_based].is_a?(String) && content[:application_id].is_a?(Fixnum)
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
@@ -17,8 +17,8 @@ class Application < ActiveRecord::Base
17
17
 
18
18
 
19
19
  after_save :save_app
20
- before_update :save_status
21
- after_update :update_app
20
+ # before_update :save_status
21
+ # after_update :update_app
22
22
 
23
23
  private
24
24
 
@@ -6,7 +6,7 @@ require_relative 'assignment'
6
6
 
7
7
  class Engine < ActiveRecord::Base
8
8
 
9
- validates_presence_of :name, :action_based
9
+ validates_presence_of :name
10
10
  has_one :engine_data
11
11
  belongs_to :application
12
12
  has_many :actions, through: :assignments
@@ -14,8 +14,8 @@ class User < ActiveRecord::Base
14
14
  has_many :applications, dependent: :destroy
15
15
 
16
16
  after_save :save_user
17
- before_update :save_status
18
- after_update :update_user
17
+ # before_update :save_status
18
+ # after_update :update_user
19
19
 
20
20
  private
21
21
 
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: {13 => {name: "apachou"},11 => {name: "site du zerou"}} }
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: 'passe'}}
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: 'modou'+nb.to_s,password: 'passeraa',firstname: 'Ndeye Fatou', lastname: 'Dieng',email: 'ab'+nb.to_s+'@gmail.com',gender: 'M'}} }
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: 'Wikina'+nb.to_s,api_key: api_key,url: 'http://www.wiki'+nb.to_s+'.com',user_id: 2}} }
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: 'reco'+nb.to_s,action_based: 'like',application_id: 2}} }
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.2
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-20 00:00:00.000000000 Z
11
+ date: 2014-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler