dimelo_ccp_api 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +6 -0
- data/.ruby-version +1 -0
- data/.travis.yml +15 -0
- data/CHANGELOG.md +29 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +59 -0
- data/Rakefile +23 -0
- data/VERSION +1 -0
- data/dimelo_ccp_api.gemspec +26 -0
- data/examples/dimelo_api_test +34 -0
- data/gemfiles/Gemfile.activesupport-3.2.x +5 -0
- data/gemfiles/Gemfile.activesupport-4.0.x +5 -0
- data/gemfiles/Gemfile.activesupport-4.1.x +5 -0
- data/gemfiles/Gemfile.activesupport-head +5 -0
- data/lib/dimelo/ccp/api/basic_object.rb +17 -0
- data/lib/dimelo/ccp/api/client.rb +46 -0
- data/lib/dimelo/ccp/api/common/openable.rb +23 -0
- data/lib/dimelo/ccp/api/common/publishable.rb +23 -0
- data/lib/dimelo/ccp/api/common/starrable.rb +23 -0
- data/lib/dimelo/ccp/api/connection.rb +86 -0
- data/lib/dimelo/ccp/api/error.rb +71 -0
- data/lib/dimelo/ccp/api/lazzy_collection.rb +114 -0
- data/lib/dimelo/ccp/api/model/answer.rb +39 -0
- data/lib/dimelo/ccp/api/model/attachment.rb +44 -0
- data/lib/dimelo/ccp/api/model/category.rb +12 -0
- data/lib/dimelo/ccp/api/model/category_group.rb +12 -0
- data/lib/dimelo/ccp/api/model/feedback.rb +20 -0
- data/lib/dimelo/ccp/api/model/feedback_comment.rb +31 -0
- data/lib/dimelo/ccp/api/model/membership.rb +12 -0
- data/lib/dimelo/ccp/api/model/private_message.rb +8 -0
- data/lib/dimelo/ccp/api/model/question.rb +20 -0
- data/lib/dimelo/ccp/api/model/role.rb +8 -0
- data/lib/dimelo/ccp/api/model/user.rb +37 -0
- data/lib/dimelo/ccp/api/model/webhook.rb +9 -0
- data/lib/dimelo/ccp/api/model.rb +209 -0
- data/lib/dimelo/ccp/api/version.rb +7 -0
- data/lib/dimelo/ccp/api.rb +62 -0
- data/lib/dimelo_ccp_api.rb +1 -0
- data/spec/examples/openable_examples.rb +37 -0
- data/spec/examples/starrable_example.rb +57 -0
- data/spec/fixtures/files/logo.jpg +0 -0
- data/spec/lib/dimelo/ccp/api/client_spec.rb +111 -0
- data/spec/lib/dimelo/ccp/api/connection_spec.rb +129 -0
- data/spec/lib/dimelo/ccp/api/model/attachment_spec.rb +26 -0
- data/spec/lib/dimelo/ccp/api/model/feedback_spec.rb +10 -0
- data/spec/lib/dimelo/ccp/api/model/question_spec.rb +10 -0
- data/spec/lib/dimelo/ccp/api/model_spec.rb +162 -0
- data/spec/spec_helper.rb +7 -0
- metadata +174 -0
@@ -0,0 +1,111 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Dimelo::CCP::API::Client do
|
4
|
+
|
5
|
+
subject do
|
6
|
+
Dimelo::CCP::API::Client.new('https://domain-test.api.users.dimelo.info:4433/1.0', 'access_token' => ENV['DIMELO_API_KEY'], :http_options => {:timeout => 80})
|
7
|
+
end
|
8
|
+
|
9
|
+
def response_error(status, error, message='')
|
10
|
+
double success?: false,
|
11
|
+
body: %Q{{
|
12
|
+
"error": "#{error}",
|
13
|
+
"message": "#{message}",
|
14
|
+
"status": #{status}
|
15
|
+
}},
|
16
|
+
status: status
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '#transport' do
|
20
|
+
|
21
|
+
it 'return an the response body' do
|
22
|
+
pending('no api key') unless ENV['DIMELO_API_KEY'].present?
|
23
|
+
json = JSON.parse(subject.transport(:get, 'check'))
|
24
|
+
expect(json).to eq({"success" => true})
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'raise InvalidAccessTokenError if token is invalid' do
|
28
|
+
expect{
|
29
|
+
subject.transport(:get, 'check', {'access_token' => 'invalid'})
|
30
|
+
}.to raise_error(Dimelo::CCP::API::InvalidAccessTokenError)
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'raise NotFoundError if path is invalid' do
|
34
|
+
expect{
|
35
|
+
subject.transport(:get, 'invalid_path', {'access_token' => 'invalid'})
|
36
|
+
}.to raise_error(Dimelo::CCP::API::NotFoundError)
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'raise NotEnabledError if api is not enabled' do
|
40
|
+
allow(subject).to receive_message_chain('connection.perform') { response_error 403, 'api_not_enabled' }
|
41
|
+
expect{
|
42
|
+
subject.transport(:get, 'check', {'access_token' => 'my-token'})
|
43
|
+
}.to raise_error(Dimelo::CCP::API::NotEnabledError)
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'raise SSLError if request should be https' do
|
47
|
+
allow(subject).to receive_message_chain('connection.perform') { response_error 412, 'routing_error' }
|
48
|
+
expect{
|
49
|
+
subject.transport(:get, 'check', {'access_token' => 'my-token'})
|
50
|
+
}.to raise_error(Dimelo::CCP::API::SslError)
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'raise InvalidUserTypeError if create user is invalid' do
|
54
|
+
allow(subject).to receive_message_chain('connection.perform') { response_error 400, 'invalid_user_type' }
|
55
|
+
expect{
|
56
|
+
subject.transport(:post, 'users', {'access_token' => 'my-token'})
|
57
|
+
}.to raise_error(Dimelo::CCP::API::InvalidUserTypeError)
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'raise DomainNotFoundError if request on invalid domain' do
|
61
|
+
client = Dimelo::CCP::API::Client.new('https://no-domain.api.users.dimelo.info:4433/1.0', :http_options => {:timeout => 80})
|
62
|
+
expect{
|
63
|
+
client.transport(:get, 'check', {'access_token' => 'my-token'})
|
64
|
+
}.to raise_error(Dimelo::CCP::API::DomainNotFoundError)
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'raise an API::Error if body is not json' do
|
68
|
+
allow(subject).to receive_message_chain('connection.perform') { double success?: false, body: 'MemCache Error', status: 500 }
|
69
|
+
expect{
|
70
|
+
subject.transport(:post, 'users', {'access_token' => 'my-token'})
|
71
|
+
}.to raise_error(Dimelo::CCP::API::Error, 'POST users - 500 MemCache Error')
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'raise an API::BaseError if error does not match defined errors' do
|
75
|
+
allow(subject).to receive_message_chain('connection.perform') { response_error 123, 'unable_action', 'cannot perform action' }
|
76
|
+
expect{
|
77
|
+
subject.transport(:post, 'users', {'access_token' => 'my-token'})
|
78
|
+
}.to raise_error(Dimelo::CCP::API::BaseError, 'error_type:unable_action - status:123 - body:cannot perform action')
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'return an the response body in case of validation error' do
|
82
|
+
pending('no api key') unless ENV['DIMELO_API_KEY'].present?
|
83
|
+
json = JSON.parse(subject.transport(:post, 'roles', {}))
|
84
|
+
expect(json).to include "error" => 'validation_error'
|
85
|
+
expect(json).to include "errors" => [{"attribute"=>"label", "type"=>"invalid", "message"=>"Label is invalid"}]
|
86
|
+
expect(json).to include "message" => "Role can't be saved"
|
87
|
+
expect(json).to include "status" => 422
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
|
92
|
+
describe '#default_parameters' do
|
93
|
+
it 'is not polluted by http_options' do
|
94
|
+
expect(subject.default_parameters).not_to include('http_options')
|
95
|
+
expect(subject.default_parameters).not_to include(:http_options)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
describe '#connection' do
|
100
|
+
|
101
|
+
it 'returns a Connection' do
|
102
|
+
expect(subject.send(:connection)).to be_kind_of(Dimelo::CCP::API::Connection)
|
103
|
+
end
|
104
|
+
|
105
|
+
it 'supports http_options' do
|
106
|
+
expect(Dimelo::CCP::API::Connection).to receive(:from_uri).with(anything,hash_including(:timeout => 80))
|
107
|
+
subject.send(:connection)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
@@ -0,0 +1,129 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Dimelo::CCP::API::Connection do
|
4
|
+
|
5
|
+
describe '.from_uri' do
|
6
|
+
|
7
|
+
let(:http_uri) { URI.parse('http://example.com:8080/foo/bar?egg=spam')}
|
8
|
+
let(:https_uri) { URI.parse('https://example.com:8080/foo/bar?egg=spam')}
|
9
|
+
|
10
|
+
it 'should infer :use_ssl => true from the scheme' do
|
11
|
+
expect(Dimelo::CCP::API::Connection).to receive(:new).with('https://example.com:8080/foo/bar?egg=spam', :use_ssl => true)
|
12
|
+
Dimelo::CCP::API::Connection.from_uri(https_uri)
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should infer :use_ssl => false from the scheme' do
|
16
|
+
expect(Dimelo::CCP::API::Connection).to receive(:new).with('http://example.com:8080/foo/bar?egg=spam', :use_ssl => false)
|
17
|
+
Dimelo::CCP::API::Connection.from_uri(http_uri)
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should support http options' do
|
21
|
+
expect(Dimelo::CCP::API::Connection).to receive(:new).with('http://example.com:8080/foo/bar?egg=spam', :use_ssl => false, :timeout => 80)
|
22
|
+
Dimelo::CCP::API::Connection.from_uri(http_uri, :timeout => 80)
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should reuse connections for same scheme/hosts/port' do
|
26
|
+
first = Dimelo::CCP::API::Connection.from_uri(http_uri)
|
27
|
+
second = Dimelo::CCP::API::Connection.from_uri(http_uri)
|
28
|
+
expect(first.object_id).to eq(second.object_id)
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '#perform' do
|
34
|
+
|
35
|
+
context 'HTTP' do
|
36
|
+
|
37
|
+
subject do
|
38
|
+
Dimelo::CCP::API::Connection.new('www.google.fr')
|
39
|
+
end
|
40
|
+
|
41
|
+
let(:request) { [:get, 'http://www.google.fr/'] }
|
42
|
+
|
43
|
+
it 'works' do
|
44
|
+
response = subject.perform(*request)
|
45
|
+
expect(response.body).to_not be_empty
|
46
|
+
expect(response).to be_success
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
context 'HTTPS' do
|
52
|
+
|
53
|
+
subject do
|
54
|
+
Dimelo::CCP::API::Connection.new('www.google.fr:443', :use_ssl => true)
|
55
|
+
end
|
56
|
+
|
57
|
+
let(:request) { [:get, 'https://www.google.fr/'] }
|
58
|
+
|
59
|
+
it 'works' do
|
60
|
+
response = subject.perform(*request)
|
61
|
+
expect(response.body).to_not be_empty
|
62
|
+
expect(response).to be_success
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
subject do
|
68
|
+
Dimelo::CCP::API::Connection.new('github.com:443')
|
69
|
+
end
|
70
|
+
|
71
|
+
let(:file) { Faraday::UploadIO.new(File.expand_path('../../../../../fixtures/files/logo.jpg', __FILE__), 'image/jpeg') }
|
72
|
+
|
73
|
+
it 'sends multipart request with attachment' do
|
74
|
+
response = subject.perform(:put, 'http://www.google.com', {:file => file})
|
75
|
+
expect(response.env[:request_headers]["Content-Type"]).to include('multipart/form-data')
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'sends multipart when containing attachment param' do
|
79
|
+
response = subject.perform(:put, 'http://www.google.com', {:file => file, :q => 'hello'})
|
80
|
+
expect(response.env[:request_headers]["Content-Type"]).to include('multipart/form-data')
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'should sends form urlencoded without attachment' do
|
84
|
+
response = subject.perform(:put, 'http://www.google.com', {:q => 'hello'})
|
85
|
+
expect(response.env[:request_headers]["Content-Type"]).to eq('application/x-www-form-urlencoded')
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'sends accept json request' do
|
89
|
+
response = subject.perform(:get, 'http://www.google.com', {:q => 'hello'})
|
90
|
+
expect(response.env[:request_headers][:accept]).to eq('application/json')
|
91
|
+
expect(response).to be_success
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'sends user_agent request' do
|
95
|
+
response = subject.perform(:get, 'http://www.google.com', {:q => 'hello'})
|
96
|
+
expect(response.env[:request_headers][:user_agent]).to eq("DimeloAPI/#{Dimelo::CCP::API::VERSION} Faraday/#{Faraday::VERSION} Ruby/#{RUBY_VERSION}")
|
97
|
+
expect(response).to be_success
|
98
|
+
end
|
99
|
+
|
100
|
+
context 'Custom user_agent with valid ASCII characters' do
|
101
|
+
let!(:custom_user_agent) { "SMCC; I asked and failed" }
|
102
|
+
|
103
|
+
subject do
|
104
|
+
Dimelo::CCP::API::Connection.new('github.com:443', :user_agent => custom_user_agent)
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'sends custom user_agent request' do
|
108
|
+
response = subject.perform(:get, 'http://www.google.com', {:q => 'hello'})
|
109
|
+
expect(response.env[:request_headers][:user_agent]).to eq("DimeloAPI/#{Dimelo::CCP::API::VERSION} (#{custom_user_agent}) Faraday/#{Faraday::VERSION} Ruby/#{RUBY_VERSION}")
|
110
|
+
expect(response).to be_success
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
context 'Custom user_agent with invalid UTF-8 characters' do
|
115
|
+
let!(:custom_user_agent) { "SMCC; J'ai demandé & j'ai échoué" }
|
116
|
+
|
117
|
+
subject do
|
118
|
+
Dimelo::CCP::API::Connection.new('github.com:443', :user_agent => custom_user_agent)
|
119
|
+
end
|
120
|
+
|
121
|
+
it 'sends custom user_agent request' do
|
122
|
+
response = subject.perform(:get, 'http://www.google.com', {:q => 'hello'})
|
123
|
+
expect(response.env[:request_headers][:user_agent]).to eq("DimeloAPI/#{Dimelo::CCP::API::VERSION} (SMCC; J'ai demand & j'ai chou) Faraday/#{Faraday::VERSION} Ruby/#{RUBY_VERSION}")
|
124
|
+
expect(response).to be_success
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Dimelo::CCP::Attachment do
|
6
|
+
let(:client) { Dimelo::CCP::API::Client.new('https://domain-test.api.answers.dimelo.info/1.0', 'access_token' => 'foo') }
|
7
|
+
|
8
|
+
describe Dimelo::CCP::QuestionAttachment do
|
9
|
+
|
10
|
+
it 'use question path' do
|
11
|
+
expect(client).to receive(:transport).with(:get, 'questions/1/attachments', {:offset=>0, :limit=>30}).and_return('[]')
|
12
|
+
Dimelo::CCP::QuestionAttachment.find({:question_id => 1}, client)
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
describe Dimelo::CCP::AnswerAttachment do
|
18
|
+
|
19
|
+
it 'use answer path' do
|
20
|
+
expect(client).to receive(:transport).with(:get, 'questions/2/answers/1/attachments', {:offset=>0, :limit=>30}).and_return('[]')
|
21
|
+
Dimelo::CCP::AnswerAttachment.find({question_id: 2, answer_id: 1}, client)
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,162 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Dimelo::CCP::API::Model do
|
4
|
+
|
5
|
+
class User < Dimelo::CCP::API::Model
|
6
|
+
path 'groups/%{group_id}/users/%{id}'
|
7
|
+
attributes :id, :firstname, :lastname
|
8
|
+
end
|
9
|
+
|
10
|
+
class BaseUser < Dimelo::CCP::API::Model
|
11
|
+
attributes :id, :firstname, :lastname
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '.new' do
|
15
|
+
|
16
|
+
it "creates user with given attributes" do
|
17
|
+
user = User.new(:id => 1, :firstname => 'Homer Jay', :lastname => 'Simpson')
|
18
|
+
expect(user.id).to eq(1)
|
19
|
+
expect(user.firstname).to eq('Homer Jay')
|
20
|
+
expect(user.lastname).to eq('Simpson')
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '.parse' do
|
26
|
+
|
27
|
+
it 'parses one json record' do
|
28
|
+
user = User.parse(%[
|
29
|
+
{
|
30
|
+
"id": 1,
|
31
|
+
"firstname": "Homer Jay",
|
32
|
+
"lastname": "Simpson"
|
33
|
+
}
|
34
|
+
])
|
35
|
+
|
36
|
+
expect(user).to be_a(User)
|
37
|
+
expect(user.id).to eq(1)
|
38
|
+
expect(user.firstname).to eq('Homer Jay')
|
39
|
+
expect(user.lastname).to eq('Simpson')
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'parses many json records' do
|
43
|
+
user = User.parse(%[
|
44
|
+
[
|
45
|
+
{
|
46
|
+
"id": 1,
|
47
|
+
"firstname": "Homer Jay",
|
48
|
+
"lastname": "Simpson"
|
49
|
+
},
|
50
|
+
{
|
51
|
+
"id": 2,
|
52
|
+
"firstname": "Marjorie 'Marge'",
|
53
|
+
"lastname": "Simpson"
|
54
|
+
}
|
55
|
+
]
|
56
|
+
])
|
57
|
+
|
58
|
+
expect(user.size).to eq(2)
|
59
|
+
user.each do |u|
|
60
|
+
expect(u).to be_a(User)
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
describe '.path' do
|
68
|
+
let(:user) { BaseUser.new }
|
69
|
+
|
70
|
+
it 'should not have leading and trailling "/" to not override path_prefix' do
|
71
|
+
expect(user.compute_path).to eq('base_users')
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'should work when computed with criteria' do
|
75
|
+
expect(user.compute_path(:id => 1)).to eq('base_users/1')
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
describe '.find' do
|
81
|
+
|
82
|
+
let(:client) { Dimelo::CCP::API::Client.new('https://domain-test.api.users.dimelo.com/1.0', 'access_token' => 'foo') }
|
83
|
+
|
84
|
+
it 'compute index path' do
|
85
|
+
expect(client).to receive(:transport).with(:get, 'groups/42/users', {:offset=>0, :limit=>30}).and_return('[]')
|
86
|
+
User.find({:group_id => 42}, client)
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'compute show path' do
|
90
|
+
expect(client).to receive(:transport).with(:get, 'groups/42/users/1', {:offset=>0, :limit=>30}).and_return('{}')
|
91
|
+
User.find({:group_id => 42, :id => 1}, client)
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'send extra criterias as payload' do
|
95
|
+
expect(client).to receive(:transport).with(:get, 'groups/42/users', {:order => 'foo', :egg => 'spam', :offset=>0, :limit=>30}).and_return('[]')
|
96
|
+
User.find({:group_id => 42, :order => 'foo', :egg => 'spam'}, client)
|
97
|
+
end
|
98
|
+
|
99
|
+
it 'send the result to .parse' do
|
100
|
+
expect(client).to receive(:transport).at_least(1).times.and_return('JSON')
|
101
|
+
expect(User).to receive(:parse).at_least(1).times.with('JSON', client)
|
102
|
+
User.find({:group_id => 42}, client)
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
106
|
+
|
107
|
+
describe '#tracked_attributes' do
|
108
|
+
|
109
|
+
before :each do
|
110
|
+
class Article < Dimelo::CCP::API::Model
|
111
|
+
attributes :id, :category_ids
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
after :each do
|
116
|
+
Object.send(:remove_const, 'Article')
|
117
|
+
end
|
118
|
+
|
119
|
+
it 'should returns only mass-assigned attributes' do
|
120
|
+
expect(Article.new(:category_ids => nil).tracked_attributes).to eq([:category_ids])
|
121
|
+
end
|
122
|
+
|
123
|
+
it 'should works on single assigning' do
|
124
|
+
article = Article.new
|
125
|
+
article.category_ids = nil
|
126
|
+
expect(article.tracked_attributes).to eq([:category_ids])
|
127
|
+
end
|
128
|
+
|
129
|
+
it 'should returns nothing if not set' do
|
130
|
+
expect(Article.new.tracked_attributes).to eq([])
|
131
|
+
end
|
132
|
+
|
133
|
+
end
|
134
|
+
|
135
|
+
describe '.submit_attributes' do
|
136
|
+
|
137
|
+
before :each do
|
138
|
+
class Article < Dimelo::CCP::API::Model
|
139
|
+
attributes :id, :category_ids
|
140
|
+
submit_attributes :id, :category_ids
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
after :each do
|
145
|
+
Object.send(:remove_const, 'Article')
|
146
|
+
end
|
147
|
+
|
148
|
+
it 'does not send param when not sent' do
|
149
|
+
expect(Article.new.submit_attributes).to eq({})
|
150
|
+
end
|
151
|
+
|
152
|
+
it 'sends only param specified' do
|
153
|
+
expect(Article.new(:id => 1).submit_attributes).to eq({:id => 1})
|
154
|
+
end
|
155
|
+
|
156
|
+
it 'sends empty string is precised' do
|
157
|
+
expect(Article.new(:id => 1, :category_ids => nil).submit_attributes).to eq({:id => 1, :category_ids => nil})
|
158
|
+
end
|
159
|
+
|
160
|
+
end
|
161
|
+
|
162
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,174 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dimelo_ccp_api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.4.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jean Boussier
|
8
|
+
- Renaud Morvan
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-10-28 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: activesupport
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ">="
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: 3.0.0
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: 3.0.0
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: activemodel
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 3.0.0
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 3.0.0
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: faraday
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
type: :runtime
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: rake
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: rspec
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '3.0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '3.0'
|
84
|
+
description: Rest API client for Dimelo CCP v2 plateform
|
85
|
+
email:
|
86
|
+
- jean.boussier@dimelo.com
|
87
|
+
- nel@w3fu.com
|
88
|
+
executables: []
|
89
|
+
extensions: []
|
90
|
+
extra_rdoc_files: []
|
91
|
+
files:
|
92
|
+
- ".gitignore"
|
93
|
+
- ".ruby-version"
|
94
|
+
- ".travis.yml"
|
95
|
+
- CHANGELOG.md
|
96
|
+
- Gemfile
|
97
|
+
- LICENSE.txt
|
98
|
+
- README.md
|
99
|
+
- Rakefile
|
100
|
+
- VERSION
|
101
|
+
- dimelo_ccp_api.gemspec
|
102
|
+
- examples/dimelo_api_test
|
103
|
+
- gemfiles/Gemfile.activesupport-3.2.x
|
104
|
+
- gemfiles/Gemfile.activesupport-4.0.x
|
105
|
+
- gemfiles/Gemfile.activesupport-4.1.x
|
106
|
+
- gemfiles/Gemfile.activesupport-head
|
107
|
+
- lib/dimelo/ccp/api.rb
|
108
|
+
- lib/dimelo/ccp/api/basic_object.rb
|
109
|
+
- lib/dimelo/ccp/api/client.rb
|
110
|
+
- lib/dimelo/ccp/api/common/openable.rb
|
111
|
+
- lib/dimelo/ccp/api/common/publishable.rb
|
112
|
+
- lib/dimelo/ccp/api/common/starrable.rb
|
113
|
+
- lib/dimelo/ccp/api/connection.rb
|
114
|
+
- lib/dimelo/ccp/api/error.rb
|
115
|
+
- lib/dimelo/ccp/api/lazzy_collection.rb
|
116
|
+
- lib/dimelo/ccp/api/model.rb
|
117
|
+
- lib/dimelo/ccp/api/model/answer.rb
|
118
|
+
- lib/dimelo/ccp/api/model/attachment.rb
|
119
|
+
- lib/dimelo/ccp/api/model/category.rb
|
120
|
+
- lib/dimelo/ccp/api/model/category_group.rb
|
121
|
+
- lib/dimelo/ccp/api/model/feedback.rb
|
122
|
+
- lib/dimelo/ccp/api/model/feedback_comment.rb
|
123
|
+
- lib/dimelo/ccp/api/model/membership.rb
|
124
|
+
- lib/dimelo/ccp/api/model/private_message.rb
|
125
|
+
- lib/dimelo/ccp/api/model/question.rb
|
126
|
+
- lib/dimelo/ccp/api/model/role.rb
|
127
|
+
- lib/dimelo/ccp/api/model/user.rb
|
128
|
+
- lib/dimelo/ccp/api/model/webhook.rb
|
129
|
+
- lib/dimelo/ccp/api/version.rb
|
130
|
+
- lib/dimelo_ccp_api.rb
|
131
|
+
- spec/examples/openable_examples.rb
|
132
|
+
- spec/examples/starrable_example.rb
|
133
|
+
- spec/fixtures/files/logo.jpg
|
134
|
+
- spec/lib/dimelo/ccp/api/client_spec.rb
|
135
|
+
- spec/lib/dimelo/ccp/api/connection_spec.rb
|
136
|
+
- spec/lib/dimelo/ccp/api/model/attachment_spec.rb
|
137
|
+
- spec/lib/dimelo/ccp/api/model/feedback_spec.rb
|
138
|
+
- spec/lib/dimelo/ccp/api/model/question_spec.rb
|
139
|
+
- spec/lib/dimelo/ccp/api/model_spec.rb
|
140
|
+
- spec/spec_helper.rb
|
141
|
+
homepage: ''
|
142
|
+
licenses: []
|
143
|
+
metadata: {}
|
144
|
+
post_install_message:
|
145
|
+
rdoc_options: []
|
146
|
+
require_paths:
|
147
|
+
- lib
|
148
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
154
|
+
requirements:
|
155
|
+
- - ">="
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0'
|
158
|
+
requirements: []
|
159
|
+
rubyforge_project: dimelo_ccp_api
|
160
|
+
rubygems_version: 2.2.2
|
161
|
+
signing_key:
|
162
|
+
specification_version: 4
|
163
|
+
summary: Dimelo CCP v2 API client
|
164
|
+
test_files:
|
165
|
+
- spec/examples/openable_examples.rb
|
166
|
+
- spec/examples/starrable_example.rb
|
167
|
+
- spec/fixtures/files/logo.jpg
|
168
|
+
- spec/lib/dimelo/ccp/api/client_spec.rb
|
169
|
+
- spec/lib/dimelo/ccp/api/connection_spec.rb
|
170
|
+
- spec/lib/dimelo/ccp/api/model/attachment_spec.rb
|
171
|
+
- spec/lib/dimelo/ccp/api/model/feedback_spec.rb
|
172
|
+
- spec/lib/dimelo/ccp/api/model/question_spec.rb
|
173
|
+
- spec/lib/dimelo/ccp/api/model_spec.rb
|
174
|
+
- spec/spec_helper.rb
|