clickmeetings 0.1.2
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 +12 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +5 -0
- data/LICENSE.txt +21 -0
- data/README.md +41 -0
- data/Rakefile +6 -0
- data/bin/console +11 -0
- data/bin/setup +8 -0
- data/clickmeetings.gemspec +31 -0
- data/lib/.DS_Store +0 -0
- data/lib/clickmeetings.rb +46 -0
- data/lib/clickmeetings/.DS_Store +0 -0
- data/lib/clickmeetings/client.rb +64 -0
- data/lib/clickmeetings/config.rb +11 -0
- data/lib/clickmeetings/engine.rb +12 -0
- data/lib/clickmeetings/exceptions.rb +19 -0
- data/lib/clickmeetings/model.rb +138 -0
- data/lib/clickmeetings/models/open_api/.keep +0 -0
- data/lib/clickmeetings/models/privatelabel/account.rb +37 -0
- data/lib/clickmeetings/models/privatelabel/conference.rb +63 -0
- data/lib/clickmeetings/models/privatelabel/profile.rb +23 -0
- data/lib/clickmeetings/version.rb +3 -0
- data/spec/clickmeetings_spec.rb +7 -0
- data/spec/client_spec.rb +37 -0
- data/spec/fixtures/delete_accounts_1_conferences_1.json +1 -0
- data/spec/fixtures/delete_models_1.json +1 -0
- data/spec/fixtures/get_accounts_1_conferences.json +1 -0
- data/spec/fixtures/get_accounts_1_conferences_1.json +1 -0
- data/spec/fixtures/get_client.json +31 -0
- data/spec/fixtures/get_models.json +1 -0
- data/spec/fixtures/get_models_1.json +1 -0
- data/spec/fixtures/post_accounts_1_conferences.json +1 -0
- data/spec/fixtures/post_models.json +1 -0
- data/spec/fixtures/put_accounts_1_conferences_1.json +1 -0
- data/spec/fixtures/put_accounts_1_disable.json +1 -0
- data/spec/fixtures/put_accounts_1_enable.json +1 -0
- data/spec/fixtures/put_models_1.json +1 -0
- data/spec/helpers/fixtures_helpers.rb +11 -0
- data/spec/helpers/webmock_helpers.rb +20 -0
- data/spec/model_spec.rb +84 -0
- data/spec/models/privatelabel/account_spec.rb +38 -0
- data/spec/models/privatelabel/conference_spec.rb +144 -0
- data/spec/models/privatelabel/profile_spec.rb +19 -0
- data/spec/shared_examples/conferences_examples.rb +6 -0
- data/spec/spec_helper.rb +19 -0
- metadata +263 -0
File without changes
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Clickmeetings
|
2
|
+
module PrivateLabel
|
3
|
+
class Account < ::Clickmeetings::Model
|
4
|
+
set_client_host Clickmeetings.config.privatelabel_host
|
5
|
+
set_client_api_key Clickmeetings.config.privatelabel_api_key
|
6
|
+
|
7
|
+
attr_accessor :account_expiration_date,
|
8
|
+
:meetings_allowed,
|
9
|
+
:package,
|
10
|
+
:trainings_allowed,
|
11
|
+
:account_status,
|
12
|
+
:api_key,
|
13
|
+
:city,
|
14
|
+
:country,
|
15
|
+
:email,
|
16
|
+
:firstname,
|
17
|
+
:lastname,
|
18
|
+
:state,
|
19
|
+
:street,
|
20
|
+
:zip_code,
|
21
|
+
:username,
|
22
|
+
:webinars_allowed
|
23
|
+
|
24
|
+
%w(enable disable).each do |m|
|
25
|
+
define_method m do
|
26
|
+
Clickmeetings.with_client(client_options) { client.put(remote_url(__method__, id: id)) }
|
27
|
+
@account_status = (m == "enable" ? "active" : "disabled")
|
28
|
+
self
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def conferences
|
33
|
+
Clickmeetings::PrivateLabel::Conference.by_account(account_id: id).all
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module Clickmeetings
|
2
|
+
module PrivateLabel
|
3
|
+
class Conference < ::Clickmeetings::Model
|
4
|
+
set_client_host Clickmeetings.config.privatelabel_host
|
5
|
+
set_client_api_key Clickmeetings.config.privatelabel_api_key
|
6
|
+
|
7
|
+
attr_accessor :id, :room_type, :room_pin, :name, :name_url, :description,
|
8
|
+
:access_type, :lobby_description, :status, :created_at,
|
9
|
+
:updated_at, :permanent_room, :ccc, :starts_at, :ends_at,
|
10
|
+
:access_role_hashes, :room_url, :phone_listener_pin,
|
11
|
+
:phone_presenter_pin, :embed_room_url, :recorder_list, :account_id
|
12
|
+
|
13
|
+
class NoAccountError < ::Clickmeetings::ClickmeetingError; end
|
14
|
+
|
15
|
+
class << self
|
16
|
+
attr_reader :account_id
|
17
|
+
|
18
|
+
def by_account(account_id: nil)
|
19
|
+
@account_id = account_id
|
20
|
+
self
|
21
|
+
end
|
22
|
+
|
23
|
+
def find(id)
|
24
|
+
fail Clickmeetings::PrivateLabel::Conference::NoAccountError if @account_id.nil?
|
25
|
+
super
|
26
|
+
end
|
27
|
+
|
28
|
+
def all
|
29
|
+
fail Clickmeetings::PrivateLabel::Conference::NoAccountError if @account_id.nil?
|
30
|
+
response = Clickmeetings.with_client(client_options) do
|
31
|
+
Clickmeetings.client.get remote_url(__method__)
|
32
|
+
end
|
33
|
+
response = response["active_conferences"] + response["inactive_conferences"]
|
34
|
+
handle_response response
|
35
|
+
end
|
36
|
+
|
37
|
+
def create(params = {})
|
38
|
+
fail Clickmeetings::PrivateLabel::Conference::NoAccountError if @account_id.nil?
|
39
|
+
super
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def initialize(params = {})
|
44
|
+
super
|
45
|
+
@account_id ||= self.class.account_id
|
46
|
+
end
|
47
|
+
|
48
|
+
def remote_url(action = nil, params = {})
|
49
|
+
url = Account.remote_path(:find, id: @account_id) + '/' + remote_path(action, params)
|
50
|
+
end
|
51
|
+
|
52
|
+
def update(params = {})
|
53
|
+
fail Clickmeetings::PrivateLabel::Conference::NoAccountError if @account_id.nil?
|
54
|
+
super
|
55
|
+
end
|
56
|
+
|
57
|
+
def destroy
|
58
|
+
fail Clickmeetings::PrivateLabel::Conference::NoAccountError if @account_id.nil?
|
59
|
+
super
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Clickmeetings
|
2
|
+
module PrivateLabel
|
3
|
+
class Profile < ::Clickmeetings::Model
|
4
|
+
set_client_host Clickmeetings.config.privatelabel_host
|
5
|
+
set_client_api_key Clickmeetings.config.privatelabel_api_key
|
6
|
+
|
7
|
+
attr_accessor :id, :account_manager_email, :email, :phone,
|
8
|
+
:account_manager_name, :account_manager_phone,
|
9
|
+
:name, :packages
|
10
|
+
|
11
|
+
class << self
|
12
|
+
delegate :get, to: :new
|
13
|
+
end
|
14
|
+
|
15
|
+
def get
|
16
|
+
response = Clickmeetings.with_client(client_options) do
|
17
|
+
Clickmeetings.client.get('client')
|
18
|
+
end
|
19
|
+
handle_response response
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/spec/client_spec.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Clickmeetings::Client do
|
4
|
+
let(:client) do
|
5
|
+
described_class.new(url: Clickmeetings.config.privatelabel_host,
|
6
|
+
api_key: Clickmeetings.config.privatelabel_api_key)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should create client", :aggregate_failures do
|
10
|
+
expect(subject.api_key).to eq Clickmeetings.config.api_key
|
11
|
+
expect(subject.url).to eq Clickmeetings.config.host
|
12
|
+
end
|
13
|
+
|
14
|
+
context "when response success" do
|
15
|
+
before(:each) { mock_api(:get, "client") }
|
16
|
+
|
17
|
+
it "gets client's info" do
|
18
|
+
res = client.get "client"
|
19
|
+
expect(res).to eq JSON.parse(File.read("./spec/fixtures/get_client.json"))
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
{
|
24
|
+
400 => Clickmeetings::BadRequestError,
|
25
|
+
401 => Clickmeetings::Unauthorized,
|
26
|
+
403 => Clickmeetings::Forbidden,
|
27
|
+
404 => Clickmeetings::NotFound,
|
28
|
+
422 => Clickmeetings::UnprocessedEntity,
|
29
|
+
500 => Clickmeetings::InternalServerError
|
30
|
+
}.each do |status, error_class|
|
31
|
+
context "when response status is #{status}" do
|
32
|
+
before(:each) { mock_api(:get, "client", status) }
|
33
|
+
subject { client.get "client" }
|
34
|
+
specify { expect { subject }.to raise_error error_class }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
{"result":"OK"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"result":"OK"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"active_conferences":[{"id":848824,"room_type":"webinar","room_pin":771574169,"name":""api test meeting"","name_url":"_api_test_meeting_","description":"","access_type":1,"lobby_description":"","status":"active","created_at":"2016-10-18T16:33:09+00:00","updated_at":"2016-10-18T16:33:09+00:00","permanent_room":true,"access_role_hashes":{"listener":"1192dbdbdd33af8e251f1b0058124fd9","presenter":"c1df57dc023fc46d62ae530058124fd9","host":"053344e0e0dd31654ad5c50058124fd9"},"room_url":"http://testnew.anysecond.com/_api_test_meeting_","phone_presenter_pin":576796,"phone_listener_pin":658743,"embed_room_url":"http://embed.anysecond.com/embed_conference.html?r=16524143848824","recorder_list":[]},{"id":848898,"room_type":"webinar","room_pin":846649935,"name":"api test meeting","name_url":"api_test_meeting","description":"","access_type":1,"lobby_description":"","status":"active","created_at":"2016-10-18T17:16:24+00:00","updated_at":"2016-10-18T17:16:24+00:00","permanent_room":true,"access_role_hashes":{"listener":"0d7743ef352160dbfa0ab00058124fd9","presenter":"7ccbc041e98a0ddb20c6c00058124fd9","host":"053344e0e0dd31654ad5c50058124fd9"},"room_url":"http://testnew.anysecond.com/api_test_meeting","phone_presenter_pin":356528,"phone_listener_pin":931648,"embed_room_url":"http://embed.anysecond.com/embed_conference.html?r=16524143848898","recorder_list":[]}],"inactive_conferences":[{"id":848553,"room_type":"webinar","room_pin":549225716,"name":"u0422u0435u0441u0442 u043au0430u043cu0435u0440u044b","name_url":"test-kameri","description":null,"access_type":1,"lobby_description":null,"status":"inactive","created_at":"2016-10-18T13:20:03+00:00","updated_at":"2016-10-18T15:30:01+00:00","permanent_room":false,"ccc":"2016-10-18 14:20:00","starts_at":"2016-10-18T14:20:00+00:00","ends_at":"2016-10-18T15:20:00+00:00","access_role_hashes":{"listener":"dda98debfc958f7884cd730058124fd8","presenter":"56b10bd08635bf7ca476ac0058124fd8","host":"9b00ee93dd03321f297ffb0058124fd8"},"room_url":"http://testnew.anysecond.com/test-kameri","phone_presenter_pin":822871,"phone_listener_pin":879413,"embed_room_url":"http://embed.anysecond.com/embed_conference.html?r=16524143848553","recorder_list":[]}]}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"id":1,"room_type":"webinar","room_pin":341254824,"name":"Тыц-тыц","name_url":"tits-tits","description":null,"access_type":1,"lobby_description":null,"status":"inactive","created_at":"2016-11-03T01:53:01+03:00","updated_at":"2016-11-03T04:00:01+03:00","permanent_room":false,"ccc":"2016-11-02 22:52:00","starts_at":"2016-11-03T01:52:00+03:00","ends_at":"2016-11-03T03:52:00+03:00","access_role_hashes":{"listener":"187044f8ea0122ebc9f0b800581b876b","presenter":"7e493a3eebe29ede87037100581b876b","host":"49442bfb92887799309b8200581b876b"},"room_url":"http://testapi.anysecond.com/tits-tits","phone_presenter_pin":111146,"phone_listener_pin":232553,"embed_room_url":"http://embed.anysecond.com/embed_conference.html?r=16531165865348","recorder_list":["http://recorder.clickmeeting.com/download/2016/11/2/rec-lw-us-5/504590/a3d9853ea0a0731224cb6d69469512d2/recording.mp4?st=p7i-zEREnyh_XoKkaiOWsg&e=1478199447"]}
|
@@ -0,0 +1,31 @@
|
|
1
|
+
{
|
2
|
+
"id":10,
|
3
|
+
"name":"Any Second",
|
4
|
+
"account_manager_name":"ClickMeeting",
|
5
|
+
"account_manager_email":"sales@clickmeeting.com",
|
6
|
+
"account_manager_phone":"+1 (888) 825-4256",
|
7
|
+
"email":"test@anysecond.com",
|
8
|
+
"packages":
|
9
|
+
[
|
10
|
+
{
|
11
|
+
"id":67,
|
12
|
+
"code":"anysecond_100",
|
13
|
+
"name":"AnySecond 100"
|
14
|
+
},
|
15
|
+
{
|
16
|
+
"id":90,
|
17
|
+
"code":"anysecond_100",
|
18
|
+
"name":"AnySecond 100 Webcams OFF"
|
19
|
+
},
|
20
|
+
{
|
21
|
+
"id":91,
|
22
|
+
"code":"anysecond_100",
|
23
|
+
"name":"AnySecond 100 Chat OFF"
|
24
|
+
},
|
25
|
+
{
|
26
|
+
"id":125,
|
27
|
+
"code":"anysecond_1000",
|
28
|
+
"name":"AnySecond 1000WC"
|
29
|
+
}
|
30
|
+
]
|
31
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
[{"username":"testcm","package":"AnySecond 100","account_expiration_date":"2017-09-27","user_details":{"id":514136,"account_status":"active","email":"vpikus@clickmeeting.com","firstname":"Vitali","lastname":"","city":"","state":"","street":"","zip_code":"","country":"BD","api_key":"052d088c234b71875dc42d559f243440a1a","profile_photo_url":null}},{"username":"testnew","package":"AnySecond 100","account_expiration_date":"2017-10-24","user_details":{"id":524143,"account_status":"active","email":"ermak95@gmail.com","firstname":"Makar","lastname":"","city":"","state":"","street":"","zip_code":"","country":"RU","api_key":"cc0fcaf158c06bcb6b023d67ea459484aef87c","profile_photo_url":null}},{"username":"qwark","package":"AnySecond 100","account_expiration_date":"2020-10-09","user_details":{"id":524641,"account_status":"active","email":"qwerwe@qwerq.qq","firstname":"qwerqwqrwe","lastname":"","city":"","state":"","street":"","zip_code":"","country":"RU","api_key":"e8f10be761b33c7206d2a792f7490f75782133","profile_photo_url":null}},{"username":"newnew","package":"AnySecond 100","account_expiration_date":"2016-11-11","user_details":{"id":526360,"account_status":"active","email":"qwqqwwq@wqqwwqqw.qw","firstname":"qwerty","lastname":"","city":"","state":"","street":"","zip_code":"","country":"RU","api_key":"5386bfc061cf44cb2790baca4121532f6b5","profile_photo_url":null}}]
|
@@ -0,0 +1 @@
|
|
1
|
+
{"id":1}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"room":{"id":1,"room_type":"webinar","room_pin":884449349,"name":"newnewn","name_url":"newnewn","description":"","access_type":1,"lobby_description":"Wait some minutes","status":"active","created_at":"2016-11-03T21:40:44+00:00","updated_at":"2016-11-03T21:40:44+00:00","permanent_room":false,"ccc":"2016-11-04 20:44:00","starts_at":"2016-11-04T20:44:00+00:00","ends_at":"2016-11-04T23:44:00+00:00","access_role_hashes":{"listener":"0cb61e2dd0ae19c8eb252900581baedc","presenter":"acd6afeeb487cd1eb6985e00581baedc","host":"49b57914e6d00ed141ea1e00581baedc"},"room_url":"http:\/\/testapi.anysecond.com\/newnewn","phone_presenter_pin":538883,"phone_listener_pin":869828,"embed_room_url":"http:\/\/embed.anysecond.com\/embed_conference.html?r=16531165866647","recorder_list":[]}}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"id":1}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"id":1,"access_type":1,"name":"New Name"}
|
@@ -0,0 +1 @@
|
|
1
|
+
true
|
@@ -0,0 +1 @@
|
|
1
|
+
true
|
@@ -0,0 +1 @@
|
|
1
|
+
{"id":2}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module ClickmeetingWebMock
|
2
|
+
def mock_api(verb = nil, action = nil, status = 200)
|
3
|
+
params = [
|
4
|
+
verb, Clickmeetings.config.privatelabel_host,
|
5
|
+
action, status
|
6
|
+
]
|
7
|
+
action_stub(*params) unless action.nil? || verb.nil?
|
8
|
+
end
|
9
|
+
|
10
|
+
def action_stub(verb, host, action, status)
|
11
|
+
stub_request(verb, "#{host}/#{action}")
|
12
|
+
.to_return(
|
13
|
+
status: status,
|
14
|
+
headers: {
|
15
|
+
'Content-Type' => 'application/json'
|
16
|
+
},
|
17
|
+
body: file_read(verb, action)
|
18
|
+
)
|
19
|
+
end
|
20
|
+
end
|
data/spec/model_spec.rb
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Clickmeetings::Model do
|
4
|
+
before(:each) do
|
5
|
+
described_class.set_client_host Clickmeetings.config.privatelabel_host
|
6
|
+
described_class.set_client_api_key Clickmeetings.config.privatelabel_api_key
|
7
|
+
end
|
8
|
+
|
9
|
+
context "class methods" do
|
10
|
+
context ".find" do
|
11
|
+
subject { described_class.find(1) }
|
12
|
+
before(:each) { mock_api(:get, "#{described_class.resource_name}/1") }
|
13
|
+
|
14
|
+
it "returns Model object", :aggregate_failures do
|
15
|
+
expect(subject).to be_instance_of described_class
|
16
|
+
expect(subject.id).to eq 1
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context ".all" do
|
21
|
+
subject { described_class.all }
|
22
|
+
before(:each) { mock_api(:get, described_class.resource_name) }
|
23
|
+
|
24
|
+
it "returns array of model objects", :aggregate_failures do
|
25
|
+
expect(subject).to be_instance_of Array
|
26
|
+
expect(subject.first).to be_instance_of described_class
|
27
|
+
expect(subject.first.id).to eq 514136
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context ".resource_name" do
|
32
|
+
subject { described_class.resource_name }
|
33
|
+
|
34
|
+
specify { expect(subject).to eq "models" }
|
35
|
+
end
|
36
|
+
|
37
|
+
context ".set_resource_name" do
|
38
|
+
subject { described_class.set_resource_name "resources" }
|
39
|
+
after { described_class.set_resource_name "models" }
|
40
|
+
|
41
|
+
specify do
|
42
|
+
expect { subject }.to change { described_class.resource_name }
|
43
|
+
.from("models").to("resources")
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context ".create" do
|
48
|
+
subject { described_class.create }
|
49
|
+
before(:each) { mock_api(:post, described_class.resource_name) }
|
50
|
+
|
51
|
+
it "returns Model objects" do
|
52
|
+
expect(subject).to be_instance_of described_class
|
53
|
+
expect(subject.id).to eq 1
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
context "instance methods" do
|
59
|
+
context "#update" do
|
60
|
+
let(:params) { {id: 2} }
|
61
|
+
let(:object) { described_class.new(id: 1) }
|
62
|
+
subject { object.update(params) }
|
63
|
+
|
64
|
+
before(:each) { mock_api(:put, "#{described_class.resource_name}/#{object.id}") }
|
65
|
+
|
66
|
+
it "returns updated Mode object" do
|
67
|
+
expect(subject).to be_instance_of described_class
|
68
|
+
expect(subject.id).to eq 2
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
context "#destroy" do
|
73
|
+
let(:object) { described_class.new(id: 1) }
|
74
|
+
subject { object.destroy }
|
75
|
+
|
76
|
+
before(:each) { mock_api(:delete, "#{described_class.resource_name}/#{object.id}") }
|
77
|
+
|
78
|
+
it "returns destroyed object" do
|
79
|
+
expect(subject).to be_instance_of described_class
|
80
|
+
expect(subject.id).to eq 1
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Clickmeetings::PrivateLabel::Account do
|
4
|
+
specify { expect(described_class.resource_name).to eq "accounts" }
|
5
|
+
|
6
|
+
context "#conferences" do
|
7
|
+
let(:object) { described_class.new(id: 1) }
|
8
|
+
subject { object.conferences }
|
9
|
+
|
10
|
+
before(:each) { mock_api(:get, "#{described_class.resource_name}/#{object.id}/conferences") }
|
11
|
+
|
12
|
+
it_behaves_like 'conferences list'
|
13
|
+
end
|
14
|
+
|
15
|
+
context "#enable" do
|
16
|
+
let(:object) { described_class.new(id: 1) }
|
17
|
+
subject { object.enable }
|
18
|
+
|
19
|
+
before(:each) { mock_api(:put, "#{described_class.resource_name}/#{object.id}/enable") }
|
20
|
+
|
21
|
+
it "responds with account object with account_status 'active'", :aggregate_failures do
|
22
|
+
expect(subject).to be_instance_of described_class
|
23
|
+
expect(subject.account_status).to eq 'active'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context "#disable" do
|
28
|
+
let(:object) { described_class.new(id: 1) }
|
29
|
+
subject { object.disable }
|
30
|
+
|
31
|
+
before(:each) { mock_api(:put, "#{described_class.resource_name}/#{object.id}/disable") }
|
32
|
+
|
33
|
+
it "responds with account object with account_status 'disabled'", :aggregate_failures do
|
34
|
+
expect(subject).to be_instance_of described_class
|
35
|
+
expect(subject.account_status).to eq 'disabled'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,144 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Clickmeetings::PrivateLabel::Conference do
|
4
|
+
context '::by_account' do
|
5
|
+
before { described_class.by_account(account_id: 1) }
|
6
|
+
after(:all) { described_class.by_account(account_id: nil) }
|
7
|
+
|
8
|
+
subject { described_class.account_id }
|
9
|
+
|
10
|
+
specify { expect(subject).to eq 1 }
|
11
|
+
|
12
|
+
context "gives account_id to objects" do
|
13
|
+
subject { described_class.new.account_id }
|
14
|
+
|
15
|
+
specify { expect(subject).to eq 1 }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'without account' do
|
20
|
+
context "::find" do
|
21
|
+
subject { described_class.find(1) }
|
22
|
+
|
23
|
+
specify do
|
24
|
+
expect { subject }.to raise_error Clickmeetings::PrivateLabel::Conference::NoAccountError
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
%w(all create).each do |method|
|
29
|
+
context "::#{method}" do
|
30
|
+
subject { described_class.send method }
|
31
|
+
|
32
|
+
specify do
|
33
|
+
expect { subject }.to raise_error Clickmeetings::PrivateLabel::Conference::NoAccountError
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
%w(update destroy).each do |method|
|
39
|
+
context "##{method}" do
|
40
|
+
subject { described_class.new.send(method) }
|
41
|
+
|
42
|
+
specify do
|
43
|
+
expect { subject }.to raise_error Clickmeetings::PrivateLabel::Conference::NoAccountError
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
context "with account" do
|
50
|
+
before { described_class.by_account(account_id: 1) }
|
51
|
+
after(:all) { described_class.by_account(account_id: nil) }
|
52
|
+
|
53
|
+
context '::find' do
|
54
|
+
subject { described_class.find(1) }
|
55
|
+
|
56
|
+
before(:each) { mock_api(:get, 'accounts/1/conferences/1') }
|
57
|
+
|
58
|
+
it "responds with Conference object" do
|
59
|
+
expect(subject).to be_instance_of described_class
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
context '::all' do
|
64
|
+
before(:each) { mock_api(:get, "accounts/1/conferences") }
|
65
|
+
subject { described_class.all }
|
66
|
+
|
67
|
+
it_behaves_like 'conferences list'
|
68
|
+
end
|
69
|
+
|
70
|
+
context '::create' do
|
71
|
+
before(:each) { mock_api(:post, "accounts/1/conferences", 201) }
|
72
|
+
let(:params) do
|
73
|
+
{
|
74
|
+
name: "New Api Room",
|
75
|
+
room_name: "new_api_room",
|
76
|
+
lobby_description: "Wait some minutes",
|
77
|
+
room_type: "webinar",
|
78
|
+
permanent_room: 0,
|
79
|
+
starts_at: "2016-11-04T23:44:39+0300",
|
80
|
+
ends_at: "2016-11-05T23:44:39+0300",
|
81
|
+
lobby_enabled: 1,
|
82
|
+
access_type: 1,
|
83
|
+
password: "qwerty"
|
84
|
+
}
|
85
|
+
end
|
86
|
+
subject { described_class.create params }
|
87
|
+
|
88
|
+
it "returns Conference object" do
|
89
|
+
expect(subject).to be_an_instance_of(described_class)
|
90
|
+
end
|
91
|
+
|
92
|
+
it "has correct properties", :aggregate_failures do
|
93
|
+
expect(subject.access_role_hashes).to eq({
|
94
|
+
"listener" => "0cb61e2dd0ae19c8eb252900581baedc",
|
95
|
+
"presenter" => "acd6afeeb487cd1eb6985e00581baedc",
|
96
|
+
"host" => "49b57914e6d00ed141ea1e00581baedc"
|
97
|
+
})
|
98
|
+
expect(subject.access_type).to eq 1
|
99
|
+
expect(subject.account_id).to eq 1
|
100
|
+
expect(subject.ccc).to eq "2016-11-04 20:44:00"
|
101
|
+
expect(subject.created_at).to eq "2016-11-03T21:40:44+00:00"
|
102
|
+
expect(subject.description).to eq ""
|
103
|
+
expect(subject.embed_room_url).to eq "http://embed.anysecond.com/embed_conference.html?r=16531165866647"
|
104
|
+
expect(subject.ends_at).to eq "2016-11-04T23:44:00+00:00"
|
105
|
+
expect(subject.id).to eq 1
|
106
|
+
expect(subject.lobby_description).to eq "Wait some minutes"
|
107
|
+
expect(subject.name).to eq "newnewn"
|
108
|
+
expect(subject.name_url).to eq "newnewn"
|
109
|
+
expect(subject.permanent_room).to be_falsey
|
110
|
+
expect(subject.phone_listener_pin).to eq 869828
|
111
|
+
expect(subject.phone_presenter_pin).to eq 538883
|
112
|
+
expect(subject.recorder_list).to be_empty
|
113
|
+
expect(subject.room_pin).to eq 884449349
|
114
|
+
expect(subject.room_type).to eq "webinar"
|
115
|
+
expect(subject.room_url).to eq "http://testapi.anysecond.com/newnewn"
|
116
|
+
expect(subject.starts_at).to eq "2016-11-04T20:44:00+00:00"
|
117
|
+
expect(subject.status).to eq "active"
|
118
|
+
expect(subject.updated_at).to eq "2016-11-03T21:40:44+00:00"
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
context '#update' do
|
123
|
+
let(:object) { described_class.new(id: 1, access_type: 3, name: 'New Name') }
|
124
|
+
subject { object.update access_type: 1 }
|
125
|
+
|
126
|
+
before(:each) { mock_api(:put, 'accounts/1/conferences/1') }
|
127
|
+
|
128
|
+
specify { expect(subject).to be_an_instance_of described_class }
|
129
|
+
|
130
|
+
it "returns updated object" do
|
131
|
+
expect(subject.access_type).to eq 1
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
context "#destroy" do
|
136
|
+
let(:object) { described_class.new(id: 1, name: "Name") }
|
137
|
+
subject { object.destroy }
|
138
|
+
|
139
|
+
before(:each) { mock_api(:delete, 'accounts/1/conferences/1') }
|
140
|
+
|
141
|
+
specify { expect(subject).to be_an_instance_of described_class }
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|