citrix 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +12 -4
- data/CHANGELOG.md +8 -0
- data/README.md +5 -5
- data/Rakefile +7 -4
- data/citrix.gemspec +17 -15
- data/lib/citrix.rb +2 -2
- data/lib/citrix/training.rb +15 -15
- data/lib/citrix/training/helpers/http_client.rb +5 -5
- data/lib/citrix/training/namespace/registrants.rb +8 -8
- data/lib/citrix/training/namespace/trainings.rb +9 -9
- data/lib/citrix/training/serializer/registrant.rb +7 -7
- data/lib/citrix/training/serializer/training.rb +9 -9
- data/lib/citrix/version.rb +1 -1
- data/test/citrix/training/client_test.rb +18 -0
- data/test/citrix/training/credentials_test.rb +27 -0
- data/test/citrix/training/helpers/http_client_test.rb +45 -0
- data/test/citrix/training/helpers/initializer_test.rb +15 -0
- data/test/citrix/training/namespace/registrants_test.rb +95 -0
- data/test/citrix/training/namespace/trainings_test.rb +111 -0
- data/test/citrix/training/resource/registrant_test.rb +23 -0
- data/test/citrix/training/resource/training_test.rb +25 -0
- data/test/citrix/training/serializer/registrant_test.rb +53 -0
- data/test/citrix/training/serializer/training_date_test.rb +21 -0
- data/test/citrix/training/serializer/training_test.rb +82 -0
- data/{spec → test}/fixtures/register.json +0 -0
- data/{spec → test}/fixtures/registrant.json +1 -1
- data/{spec → test}/fixtures/registrants.json +0 -0
- data/{spec → test}/fixtures/training.json +0 -0
- data/{spec → test}/fixtures/trainings.json +0 -0
- data/{spec/spec_helper.rb → test/test_helper.rb} +24 -37
- metadata +67 -40
- data/.rspec +0 -1
- data/spec/citrix/training/client_spec.rb +0 -22
- data/spec/citrix/training/credentials_spec.rb +0 -31
- data/spec/citrix/training/helpers/http_client_spec.rb +0 -54
- data/spec/citrix/training/helpers/initializer_spec.rb +0 -15
- data/spec/citrix/training/namespace/registrants_spec.rb +0 -94
- data/spec/citrix/training/namespace/trainings_spec.rb +0 -109
- data/spec/citrix/training/resource/registrant_spec.rb +0 -11
- data/spec/citrix/training/resource/training_spec.rb +0 -11
- data/spec/citrix/training/serializer/registrant_spec.rb +0 -50
- data/spec/citrix/training/serializer/training_date_spec.rb +0 -21
- data/spec/citrix/training/serializer/training_spec.rb +0 -79
@@ -1,109 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Citrix::Training::Namespace::Trainings do
|
4
|
-
describe '#create' do
|
5
|
-
let(:client) { build_client }
|
6
|
-
|
7
|
-
it 'performs request' do
|
8
|
-
stub_request(:post, /.+/)
|
9
|
-
|
10
|
-
url = url_for('organizers', client.credentials.organizer_key, 'trainings')
|
11
|
-
attrs = build_training_attributes
|
12
|
-
serialized_attrs = serialize(attrs, Citrix::Training::Serializer::Training)
|
13
|
-
client.trainings.create(attrs)
|
14
|
-
|
15
|
-
expect(last_request.method).to eq(:post)
|
16
|
-
expect(last_request.uri.normalize.to_s).to eq(url)
|
17
|
-
expect(last_request.body).to eq(JSON.dump(serialized_attrs))
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'returns response' do
|
21
|
-
stub_request(:post, /.+/)
|
22
|
-
response, training = client.trainings.create({})
|
23
|
-
expect(response).to be_a(Aitch::Response)
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'returns training instance' do
|
27
|
-
stub_request(:post, /.+/)
|
28
|
-
response, training = client.trainings.create({})
|
29
|
-
expect(training).to be_a(Citrix::Training::Resource::Training)
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'sets training key' do
|
33
|
-
stub_request(:post, /.+/).to_return(body: '"1234"', status: 201)
|
34
|
-
response, training = client.trainings.create({})
|
35
|
-
expect(training.key).to eq('1234')
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
describe '#all' do
|
40
|
-
let(:client) { build_client }
|
41
|
-
|
42
|
-
it 'performs request' do
|
43
|
-
stub_request(:get, /.+/).to_return(body: '[]', headers: {'Content-Type' => 'application/json'})
|
44
|
-
|
45
|
-
url = url_for('organizers', client.credentials.organizer_key, 'trainings')
|
46
|
-
client.trainings.all
|
47
|
-
|
48
|
-
expect(last_request.method).to eq(:get)
|
49
|
-
expect(last_request.uri.normalize.to_s).to eq(url)
|
50
|
-
end
|
51
|
-
|
52
|
-
it 'returns trainings' do
|
53
|
-
stub_request(:get, /.+/)
|
54
|
-
.to_return(status: 200, body: fixtures.join('trainings.json').read, headers: {'Content-Type' => 'application/json'})
|
55
|
-
|
56
|
-
response, trainings = client.trainings.all
|
57
|
-
|
58
|
-
expect(trainings.size).to eq(1)
|
59
|
-
expect(trainings.first).to be_a(Citrix::Training::Resource::Training)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
describe '#find' do
|
64
|
-
let(:client) { build_client }
|
65
|
-
|
66
|
-
it 'performs request' do
|
67
|
-
stub_request(:get, /.+/)
|
68
|
-
.to_return(status: 200, body: fixtures.join('training.json').read, headers: {'Content-Type' => 'application/json'})
|
69
|
-
client.trainings.find('1234')
|
70
|
-
|
71
|
-
url = url_for('organizers', client.credentials.organizer_key, 'trainings', '1234')
|
72
|
-
|
73
|
-
expect(last_request.method).to eq(:get)
|
74
|
-
expect(last_request.uri.normalize.to_s).to eq(url)
|
75
|
-
end
|
76
|
-
|
77
|
-
it 'returns training' do
|
78
|
-
stub_request(:get, /.+/)
|
79
|
-
.to_return(status: 200, body: fixtures.join('training.json').read, headers: {'Content-Type' => 'application/json'})
|
80
|
-
|
81
|
-
response, training = client.trainings.find('1234')
|
82
|
-
|
83
|
-
expect(training).to be_a(Citrix::Training::Resource::Training)
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
describe '#remove' do
|
88
|
-
let(:client) { build_client }
|
89
|
-
|
90
|
-
it 'performs request' do
|
91
|
-
stub_request(:delete, /.+/)
|
92
|
-
|
93
|
-
training = build_training
|
94
|
-
url = url_for('organizers', client.credentials.organizer_key, 'trainings', training.key)
|
95
|
-
client.trainings.remove(training)
|
96
|
-
|
97
|
-
expect(last_request.method).to eq(:delete)
|
98
|
-
expect(last_request.uri.normalize.to_s).to eq(url)
|
99
|
-
end
|
100
|
-
|
101
|
-
it 'returns response' do
|
102
|
-
stub_request(:delete, /.+/)
|
103
|
-
training = build_training
|
104
|
-
response = client.trainings.remove(training)
|
105
|
-
|
106
|
-
expect(response).to be_a(Aitch::Response)
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Citrix::Training::Resource::Registrant do
|
4
|
-
let(:attributes) {
|
5
|
-
JSON.load(fixtures.join('registrant.json').read)
|
6
|
-
}
|
7
|
-
|
8
|
-
it 'loads all attributes' do
|
9
|
-
described_class.new described_class.deserialize(attributes)
|
10
|
-
end
|
11
|
-
end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Citrix::Training::Serializer::Registrant do
|
4
|
-
describe '#serialize' do
|
5
|
-
it 'returns first name' do
|
6
|
-
expect(serialize(first_name: 'NAME')).to include(givenName: 'NAME')
|
7
|
-
end
|
8
|
-
|
9
|
-
it 'returns last name' do
|
10
|
-
expect(serialize(last_name: 'NAME')).to include(surname: 'NAME')
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'returns email' do
|
14
|
-
expect(serialize(email: 'EMAIL')).to include(email: 'EMAIL')
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
describe '#deserialize' do
|
19
|
-
let(:raw_attrs) { JSON.load(fixtures.join('registrant.json').read) }
|
20
|
-
let(:attrs) { deserialize(raw_attrs) }
|
21
|
-
|
22
|
-
it 'returns first name' do
|
23
|
-
expect(attrs).to include(first_name: raw_attrs['givenName'])
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'returns last name' do
|
27
|
-
expect(attrs).to include(last_name: raw_attrs['surname'])
|
28
|
-
end
|
29
|
-
|
30
|
-
it 'returns email' do
|
31
|
-
expect(attrs).to include(email: raw_attrs['email'])
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'returns join url' do
|
35
|
-
expect(attrs).to include(join_url: raw_attrs['joinUrl'])
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'returns confirmation url' do
|
39
|
-
expect(attrs).to include(confirmation_url: raw_attrs['confirmationUrl'])
|
40
|
-
end
|
41
|
-
|
42
|
-
it 'returns registrant key' do
|
43
|
-
expect(attrs).to include(key: raw_attrs['registrantKey'])
|
44
|
-
end
|
45
|
-
|
46
|
-
it 'returns status' do
|
47
|
-
expect(attrs).to include(status: raw_attrs['status'].downcase)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Citrix::Training::Serializer::TrainingDate do
|
4
|
-
describe '#serialize' do
|
5
|
-
it 'returns starting date' do
|
6
|
-
starting = Time.now
|
7
|
-
ending = starting + 3600
|
8
|
-
params = serialize(starts_at: starting, ends_at: ending)
|
9
|
-
|
10
|
-
expect(params).to include(startDate: starting.iso8601)
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'returns ending date' do
|
14
|
-
starting = Time.now
|
15
|
-
ending = starting + 3600
|
16
|
-
params = serialize(starts_at: starting, ends_at: ending)
|
17
|
-
|
18
|
-
expect(params).to include(endDate: ending.iso8601)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,79 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Citrix::Training::Serializer::Training do
|
4
|
-
describe '#serialize' do
|
5
|
-
it 'returns name' do
|
6
|
-
expect(serialize(name: 'NAME')).to include(name: 'NAME')
|
7
|
-
end
|
8
|
-
|
9
|
-
it 'returns description' do
|
10
|
-
expect(serialize(description: 'DESCRIPTION')).to include(description: 'DESCRIPTION')
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'returns time zone' do
|
14
|
-
expect(serialize(timezone: 'TZ')).to include(timeZone: 'TZ')
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'returns registration settings (web registration)' do
|
18
|
-
params = serialize(web_registration: true)
|
19
|
-
expect(params[:registrationSettings]).to include(disableWebRegistration: false)
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'returns registration settings (confirmation email)' do
|
23
|
-
params = serialize(confirmation_email: true)
|
24
|
-
expect(params[:registrationSettings]).to include(disableConfirmationEmail: false)
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'returns dates' do
|
28
|
-
date = Citrix::Training::Resource::TrainingDate.new(Time.now, Time.now + 3600)
|
29
|
-
params = serialize(dates: [date])
|
30
|
-
|
31
|
-
expect(params[:times].size).to eq(1)
|
32
|
-
expect(params[:times].first).to include(startDate: date.starts_at.iso8601)
|
33
|
-
expect(params[:times].first).to include(endDate: date.ends_at.iso8601)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
describe '#deserialize' do
|
38
|
-
let(:attrs) {
|
39
|
-
JSON.load(fixtures.join('training.json').read)
|
40
|
-
}
|
41
|
-
|
42
|
-
it 'returns name' do
|
43
|
-
expect(deserialize(attrs)).to include(name: attrs['name'])
|
44
|
-
end
|
45
|
-
|
46
|
-
it 'returns description' do
|
47
|
-
expect(deserialize(attrs)).to include(description: attrs['description'])
|
48
|
-
end
|
49
|
-
|
50
|
-
it 'returns time zone' do
|
51
|
-
expect(deserialize(attrs)).to include(timezone: attrs['timeZone'])
|
52
|
-
end
|
53
|
-
|
54
|
-
it 'returns key' do
|
55
|
-
expect(deserialize(attrs)).to include(key: attrs['trainingKey'])
|
56
|
-
end
|
57
|
-
|
58
|
-
it 'returns dates' do
|
59
|
-
params = deserialize(attrs)
|
60
|
-
|
61
|
-
starts_at = Time.parse(attrs['times'][0]['startDate'])
|
62
|
-
ends_at = Time.parse(attrs['times'][0]['endDate'])
|
63
|
-
|
64
|
-
expect(params[:dates].size).to eq(1)
|
65
|
-
expect(params[:dates].first.starts_at.to_i).to eq(starts_at.to_i)
|
66
|
-
expect(params[:dates].first.ends_at.to_i).to eq(ends_at.to_i)
|
67
|
-
end
|
68
|
-
|
69
|
-
it 'returns web registration' do
|
70
|
-
params = deserialize(attrs)
|
71
|
-
expect(params).to include(web_registration: true)
|
72
|
-
end
|
73
|
-
|
74
|
-
it 'returns confirmation e-mail' do
|
75
|
-
params = deserialize(attrs)
|
76
|
-
expect(params).to include(confirmation_email: true)
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|