ribose 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +539 -970
- data/.sample.pryrc +4 -0
- data/CHANGELOG.md +5 -0
- data/README.md +539 -3
- data/bin/console +2 -5
- data/lib/ribose.rb +31 -1
- data/lib/ribose/actions.rb +10 -0
- data/lib/ribose/actions/all.rb +43 -0
- data/lib/ribose/actions/base.rb +11 -0
- data/lib/ribose/actions/create.rb +44 -0
- data/lib/ribose/actions/delete.rb +32 -0
- data/lib/ribose/actions/fetch.rb +44 -0
- data/lib/ribose/actions/update.rb +35 -0
- data/lib/ribose/app_data.rb +15 -0
- data/lib/ribose/app_relation.rb +12 -0
- data/lib/ribose/base.rb +48 -0
- data/lib/ribose/calendar.rb +22 -0
- data/lib/ribose/client.rb +31 -0
- data/lib/ribose/config.rb +21 -0
- data/lib/ribose/configuration.rb +25 -0
- data/lib/ribose/connection.rb +39 -0
- data/lib/ribose/connection_invitation.rb +51 -0
- data/lib/ribose/conversation.rb +87 -0
- data/lib/ribose/error.rb +30 -0
- data/lib/ribose/feed.rb +11 -0
- data/lib/ribose/file_uploader.rb +93 -0
- data/lib/ribose/join_space_request.rb +41 -0
- data/lib/ribose/leaderboard.rb +19 -0
- data/lib/ribose/member.rb +34 -0
- data/lib/ribose/message.rb +94 -0
- data/lib/ribose/profile.rb +56 -0
- data/lib/ribose/request.rb +122 -0
- data/lib/ribose/resource_helper.rb +81 -0
- data/lib/ribose/response/raise_error.rb +15 -0
- data/lib/ribose/rspec.rb +19 -0
- data/lib/ribose/session.rb +48 -0
- data/lib/ribose/setting.rb +16 -0
- data/lib/ribose/space.rb +30 -0
- data/lib/ribose/space_file.rb +49 -0
- data/lib/ribose/space_invitation.rb +70 -0
- data/lib/ribose/stream.rb +15 -0
- data/lib/ribose/user.rb +42 -0
- data/lib/ribose/version.rb +1 -1
- data/lib/ribose/widget.rb +11 -0
- data/lib/ribose/wiki.rb +80 -0
- data/ribose.gemspec +6 -0
- data/spec/fixtures/app_data.json +188 -0
- data/spec/fixtures/app_relation.json +19 -0
- data/spec/fixtures/app_relations.json +89 -0
- data/spec/fixtures/calendar.json +12 -0
- data/spec/fixtures/calendars.json +34 -0
- data/spec/fixtures/connection_invitation.json +26 -0
- data/spec/fixtures/connection_invitation_accepted.json +26 -0
- data/spec/fixtures/connection_invitations.json +28 -0
- data/spec/fixtures/connection_invitations_created.json +37 -0
- data/spec/fixtures/connection_suggestion.json +22 -0
- data/spec/fixtures/connections.json +28 -0
- data/spec/fixtures/conversation.json +26 -0
- data/spec/fixtures/conversation_created.json +31 -0
- data/spec/fixtures/conversations.json +34 -0
- data/spec/fixtures/empty.json +1 -0
- data/spec/fixtures/feeds.json +84 -0
- data/spec/fixtures/file_upload_prepared.json +17 -0
- data/spec/fixtures/file_uploaded.json +38 -0
- data/spec/fixtures/general_information.json +16 -0
- data/spec/fixtures/join_space_request_created.json +26 -0
- data/spec/fixtures/join_space_request_updated.json +25 -0
- data/spec/fixtures/join_space_requests.json +34 -0
- data/spec/fixtures/leaderboard.json +21 -0
- data/spec/fixtures/login.html +323 -0
- data/spec/fixtures/members.json +20 -0
- data/spec/fixtures/message.json +22 -0
- data/spec/fixtures/messages.json +24 -0
- data/spec/fixtures/ping.json +3 -0
- data/spec/fixtures/profile.json +10 -0
- data/spec/fixtures/sample.png +0 -0
- data/spec/fixtures/setting.json +16 -0
- data/spec/fixtures/settings.json +18 -0
- data/spec/fixtures/space.json +59 -0
- data/spec/fixtures/space_created.json +59 -0
- data/spec/fixtures/space_file.json +58 -0
- data/spec/fixtures/space_invitation.json +32 -0
- data/spec/fixtures/space_invitation_updated.json +35 -0
- data/spec/fixtures/space_invitations.json +34 -0
- data/spec/fixtures/space_mass_invitations.json +46 -0
- data/spec/fixtures/spaces.json +61 -0
- data/spec/fixtures/stream.json +176 -0
- data/spec/fixtures/user_activated.json +6 -0
- data/spec/fixtures/widgets.json +50 -0
- data/spec/fixtures/wiki.json +79 -0
- data/spec/fixtures/wikis.json +197 -0
- data/spec/ribose/actions/create_spec.rb +40 -0
- data/spec/ribose/actions/delete_spec.rb +24 -0
- data/spec/ribose/actions/fetch_spec.rb +32 -0
- data/spec/ribose/actions/update_spec.rb +36 -0
- data/spec/ribose/app_data_spec.rb +15 -0
- data/spec/ribose/app_relation_spec.rb +27 -0
- data/spec/ribose/calendar_spec.rb +50 -0
- data/spec/ribose/client_spec.rb +48 -0
- data/spec/ribose/config_spec.rb +41 -0
- data/spec/ribose/connection_invitation_spec.rb +79 -0
- data/spec/ribose/connection_spec.rb +26 -0
- data/spec/ribose/conversation_spec.rb +84 -0
- data/spec/ribose/error_spec.rb +67 -0
- data/spec/ribose/feed_spec.rb +14 -0
- data/spec/ribose/file_uploader_spec.rb +30 -0
- data/spec/ribose/join_space_request_spec.rb +70 -0
- data/spec/ribose/leaderboard_spec.rb +13 -0
- data/spec/ribose/member_spec.rb +16 -0
- data/spec/ribose/message_spec.rb +69 -0
- data/spec/ribose/profile_spec.rb +40 -0
- data/spec/ribose/request_spec.rb +66 -0
- data/spec/ribose/resource_helper_spec.rb +58 -0
- data/spec/ribose/session_spec.rb +46 -0
- data/spec/ribose/setting_spec.rb +40 -0
- data/spec/ribose/space_file_spec.rb +41 -0
- data/spec/ribose/space_invitation_spec.rb +117 -0
- data/spec/ribose/space_spec.rb +70 -0
- data/spec/ribose/stream_spec.rb +14 -0
- data/spec/ribose/user_spec.rb +48 -0
- data/spec/ribose/widget_spec.rb +14 -0
- data/spec/ribose/wiki_spec.rb +67 -0
- data/spec/spec_helper.rb +11 -0
- data/spec/support/fake_ribose_api.rb +431 -0
- data/spec/support/file_upload_stub.rb +76 -0
- metadata +190 -3
- data/spec/ribose_spec.rb +0 -4
@@ -0,0 +1,46 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe Ribose::Session do
|
4
|
+
describe ".create" do
|
5
|
+
it "creates a new user session" do
|
6
|
+
username = "super.user"
|
7
|
+
password = "supper.secreet.password"
|
8
|
+
|
9
|
+
stub_session_creation_request_via_web
|
10
|
+
session = Ribose::Session.create(username: username, password: password)
|
11
|
+
|
12
|
+
expect(session["created_at"]).not_to be_nil
|
13
|
+
expect(session["authentication_token"]).to eq("user-super-secret-token")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def login_url
|
18
|
+
ribose_url_for("login")
|
19
|
+
end
|
20
|
+
|
21
|
+
def ribose_url_for(*endpoints)
|
22
|
+
[Ribose.configuration.web_url, *endpoints].join("/")
|
23
|
+
end
|
24
|
+
|
25
|
+
def stub_session_creation_request_via_web
|
26
|
+
stub_get_request_with_login_page
|
27
|
+
stub_post_request_with_empty_body
|
28
|
+
stub_general_inforomation_request
|
29
|
+
end
|
30
|
+
|
31
|
+
def stub_get_request_with_login_page
|
32
|
+
stub_request(:get, login_url).and_return(
|
33
|
+
body: ribose_fixture("login", "html"),
|
34
|
+
headers: { content_type: "text/html" },
|
35
|
+
)
|
36
|
+
end
|
37
|
+
|
38
|
+
def stub_general_inforomation_request
|
39
|
+
stub_request(:get, ribose_url_for(["settings", "general", "info"])).
|
40
|
+
and_return(body: ribose_fixture("general_information"), status: 200)
|
41
|
+
end
|
42
|
+
|
43
|
+
def stub_post_request_with_empty_body
|
44
|
+
stub_request(:post, login_url).and_return(body: ribose_fixture("empty"))
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe Ribose::Setting do
|
4
|
+
describe ".all" do
|
5
|
+
it "lists the user settings" do
|
6
|
+
stub_ribose_setting_list_api
|
7
|
+
settings = Ribose::Setting.all
|
8
|
+
|
9
|
+
expect(settings.first.id).not_to be_nil
|
10
|
+
expect(settings.first.type).to eq("Setting::Personal")
|
11
|
+
expect(settings.first.time_zone_detected).to eq("Asia/Bangkok")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe ".fetch" do
|
16
|
+
it "fetches the details for a setting" do
|
17
|
+
setting_id = 123_456_789
|
18
|
+
stub_ribose_setting_find_api(setting_id)
|
19
|
+
setting = Ribose::Setting.fetch(setting_id)
|
20
|
+
|
21
|
+
expect(setting.id).to eq(setting_id)
|
22
|
+
expect(setting.type).to eq("Setting::Personal")
|
23
|
+
expect(setting.time_zone_detected).to eq("Asia/Bangkok")
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe ".update" do
|
28
|
+
it "updates a setting with provided details" do
|
29
|
+
new_theme_id = 6
|
30
|
+
setting_id = 123_456_789
|
31
|
+
|
32
|
+
stub_ribose_setting_update_api(setting_id, theme_id: new_theme_id)
|
33
|
+
setting = Ribose::Setting.update(setting_id, theme_id: new_theme_id)
|
34
|
+
|
35
|
+
expect(setting.id).to eq(setting_id)
|
36
|
+
expect(setting.type).to eq("Setting::Personal")
|
37
|
+
expect(setting.theme_id).to eq(new_theme_id.to_s)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe Ribose::SpaceFile do
|
4
|
+
describe ".all" do
|
5
|
+
it "retrieve files uploaded to a spce" do
|
6
|
+
space_id = 123_456_789
|
7
|
+
stub_ribose_space_file_list(space_id)
|
8
|
+
|
9
|
+
files = Ribose::SpaceFile.all(space_id)
|
10
|
+
|
11
|
+
expect(files.first.id).not_to be_nil
|
12
|
+
expect(files.first.name).to eq("sample-file.png")
|
13
|
+
expect(files.first.versions.first.version).to eq(1)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe ".create" do
|
18
|
+
it "creates a new file with provided details" do
|
19
|
+
space_id = 123_456_789
|
20
|
+
|
21
|
+
stub_ribose_space_file_upload_api(space_id, file_attributes)
|
22
|
+
file = Ribose::SpaceFile.create(space_id, file_attributes)
|
23
|
+
|
24
|
+
expect(file.id).not_to be_nil
|
25
|
+
expect(file.author).to eq("John Doe")
|
26
|
+
expect(file.content_type).to eq("image/png")
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def file_attributes
|
31
|
+
{
|
32
|
+
file: sample_fixture_file,
|
33
|
+
description: "This is a sample file",
|
34
|
+
tag_list: "Details tag for the file",
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
def sample_fixture_file
|
39
|
+
@sample_file ||= File.join(Ribose.root, "spec/fixtures/sample.png")
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,117 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe Ribose::SpaceInvitation do
|
4
|
+
describe ".all" do
|
5
|
+
it "retrieves the list of space invitations" do
|
6
|
+
stub_ribose_space_invitation_lis_api
|
7
|
+
invitations = Ribose::SpaceInvitation.all
|
8
|
+
|
9
|
+
expect(invitations.count).to eq(1)
|
10
|
+
expect(invitations.first.type).to eq("Invitation::ToSpace")
|
11
|
+
expect(invitations.first.space.name).to eq("The CLI Space")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe ".create" do
|
16
|
+
it "creates an invitation to a specific space" do
|
17
|
+
stub_ribose_space_invitation_create_api(invitation_attributes)
|
18
|
+
invitation = Ribose::SpaceInvitation.create(invitation_attributes)
|
19
|
+
|
20
|
+
expect(invitation.id).not_to be_nil
|
21
|
+
expect(invitation.inviter.name).to eq("John Doe")
|
22
|
+
expect(invitation.type).to eq("Invitation::ToSpace")
|
23
|
+
expect(invitation.space.name).to eq("Trip to Mars!")
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe ".mass_create" do
|
28
|
+
it "creates multiple inviations to a space" do
|
29
|
+
space_id = 123_456_789
|
30
|
+
|
31
|
+
attributes = {
|
32
|
+
role_ids: [123_456_789],
|
33
|
+
emails: ["jennie.doe@example.com"],
|
34
|
+
body: "Hi, I would like to join you to this space",
|
35
|
+
}
|
36
|
+
|
37
|
+
stub_ribose_space_invitation_mass_create(space_id, attributes)
|
38
|
+
invitation = Ribose::SpaceInvitation.mass_create(space_id, attributes)
|
39
|
+
|
40
|
+
expect(
|
41
|
+
invitation.success.emails.first[0].to_s,
|
42
|
+
).to eq(attributes[:emails].first.to_s)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe ".update" do
|
47
|
+
it "updates a space invitation" do
|
48
|
+
invitation_id = 123_456_789
|
49
|
+
attributes = { role_id: 123 }
|
50
|
+
|
51
|
+
stub_ribose_space_invitation_update_api(invitation_id, attributes)
|
52
|
+
invitation = Ribose::SpaceInvitation.update(invitation_id, attributes)
|
53
|
+
|
54
|
+
expect(invitation.id).not_to be_nil
|
55
|
+
expect(invitation.role_id).not_to be_nil
|
56
|
+
expect(invitation.type).to eq("Invitation::ToSpace")
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe ".accept" do
|
61
|
+
it "accepts a space invitation" do
|
62
|
+
invitation_id = 123_456_789
|
63
|
+
stub_ribose_space_invitation_update_api(invitation_id, state: 1)
|
64
|
+
|
65
|
+
invitation = Ribose::SpaceInvitation.accept(invitation_id)
|
66
|
+
|
67
|
+
expect(invitation.state).to eq(1)
|
68
|
+
expect(invitation.id).not_to be_nil
|
69
|
+
expect(invitation.type).to eq("Invitation::ToSpace")
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe ".resend" do
|
74
|
+
it "resends a space invitation to non-member email" do
|
75
|
+
invitation_id = 123_456_789
|
76
|
+
|
77
|
+
stub_ribose_space_invitation_resend_api(invitation_id)
|
78
|
+
invitation = Ribose::SpaceInvitation.resend(invitation_id)
|
79
|
+
|
80
|
+
expect(invitation.to_space).not_to be_nil
|
81
|
+
expect(invitation.to_space.id).not_to be_nil
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
describe ".reject" do
|
86
|
+
it "rejects a space invitation" do
|
87
|
+
invitation_id = 123_456_789
|
88
|
+
stub_ribose_space_invitation_update_api(invitation_id, state: 2)
|
89
|
+
|
90
|
+
invitation = Ribose::SpaceInvitation.reject(invitation_id)
|
91
|
+
|
92
|
+
expect(invitation.id).not_to be_nil
|
93
|
+
expect(invitation.state).not_to be_nil
|
94
|
+
expect(invitation.type).to eq("Invitation::ToSpace")
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
describe ".cancel" do
|
99
|
+
it "cancels a space invitation" do
|
100
|
+
invitation_id = 123_456_789
|
101
|
+
stub_ribose_space_invitation_cancel_api(invitation_id)
|
102
|
+
|
103
|
+
expect do
|
104
|
+
Ribose::SpaceInvitation.cancel(invitation_id)
|
105
|
+
end.not_to raise_error
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
def invitation_attributes
|
110
|
+
@invitation ||= {
|
111
|
+
state: "0",
|
112
|
+
body: "Please join!",
|
113
|
+
space_id: "123_456_789",
|
114
|
+
invitee_id: "456_789_012",
|
115
|
+
}
|
116
|
+
end
|
117
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe Ribose::Space do
|
4
|
+
describe ".all" do
|
5
|
+
it "retrieves the list of user spaces" do
|
6
|
+
stub_ribose_space_list_api
|
7
|
+
spaces = Ribose::Space.all
|
8
|
+
|
9
|
+
expect(spaces.first.id).to eq("0e8d5c16-1a31-4df9-83d9-eeaa374d5adc")
|
10
|
+
expect(spaces.first.name).to eq("Work")
|
11
|
+
expect(spaces.first.visibility).to eq("invisible")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe ".fetch" do
|
16
|
+
it "fetches a specific user space" do
|
17
|
+
space_id = 123_456_789
|
18
|
+
|
19
|
+
stub_ribose_space_fetch_api(space_id)
|
20
|
+
space = Ribose::Space.fetch(space_id)
|
21
|
+
|
22
|
+
expect(space.id).not_to be_nil
|
23
|
+
expect(space.name).to eq("Work")
|
24
|
+
expect(space.role_name).to eq("Administrator")
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe ".create" do
|
29
|
+
it "creates a new space with provided details" do
|
30
|
+
stub_ribose_space_create_api(space_attributes)
|
31
|
+
space = Ribose::Space.create(space_attributes)
|
32
|
+
|
33
|
+
expect(space.id).not_to be_nil
|
34
|
+
expect(space.visibility).to eq("invisible")
|
35
|
+
expect(space.name).to eq("Trip to the Mars")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe ".update" do
|
40
|
+
it "updates a space with provided details" do
|
41
|
+
space_id = 123_456_789
|
42
|
+
|
43
|
+
stub_ribose_space_update_api(space_id, space_attributes)
|
44
|
+
space = Ribose::Space.update(space_id, space_attributes)
|
45
|
+
|
46
|
+
expect(space.id).not_to be_nil
|
47
|
+
expect(space.visibility).to eq("invisible")
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe ".remove" do
|
52
|
+
it "removes an existing space" do
|
53
|
+
space_uuid = "8c63c209-8b98-41aa-a320-336462476ea1"
|
54
|
+
stub_ribose_space_remove_api(space_uuid, confirmation: true)
|
55
|
+
|
56
|
+
expect do
|
57
|
+
Ribose::Space.remove(space_uuid, confirmation: true)
|
58
|
+
end.not_to raise_error
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def space_attributes
|
63
|
+
{
|
64
|
+
access: "private",
|
65
|
+
space_category_id: 12,
|
66
|
+
description: "The long awaited dream!",
|
67
|
+
name: "Trip to the Mars",
|
68
|
+
}
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe Ribose::Stream do
|
4
|
+
describe ".all" do
|
5
|
+
it "retreives the list of notifications stream" do
|
6
|
+
stub_ribose_stream_list_api
|
7
|
+
stream = Ribose::Stream.all
|
8
|
+
|
9
|
+
expect(stream.notifications.count).to eq(3)
|
10
|
+
expect(stream.notifications.first.id).not_to be_nil
|
11
|
+
expect(stream.notifications.first.data.first.info.action).to eq("create")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe Ribose::User do
|
4
|
+
before { restore_to_default_config }
|
5
|
+
after { set_configuration_for_test_env }
|
6
|
+
|
7
|
+
describe ".create" do
|
8
|
+
it "creates a new signup request for user" do
|
9
|
+
user_attributes = { email: "john.doe@example.com" }
|
10
|
+
stub_ribose_app_user_create_api(user_attributes)
|
11
|
+
|
12
|
+
expect do
|
13
|
+
Ribose::User.create(user_attributes)
|
14
|
+
end.not_to raise_error
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe ".activate" do
|
19
|
+
it "complete the user signup process" do
|
20
|
+
stub_ribose_app_user_activate_api(user_attributes)
|
21
|
+
user = Ribose::User.activate(user_attributes)
|
22
|
+
|
23
|
+
expect(user.id).not_to be_nil
|
24
|
+
expect(user.name).to eq("John Doe")
|
25
|
+
expect(user.connected).to be_truthy
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def user_attributes
|
30
|
+
@user_attributes ||= {
|
31
|
+
email: "john.doe@example.com",
|
32
|
+
password: "SecurePassword",
|
33
|
+
otp: "OTP_RECEIVED_VIA_EMAIL",
|
34
|
+
}
|
35
|
+
end
|
36
|
+
|
37
|
+
def restore_to_default_config
|
38
|
+
Ribose.configuration.api_token = nil
|
39
|
+
Ribose.configuration.user_email = nil
|
40
|
+
end
|
41
|
+
|
42
|
+
def set_configuration_for_test_env
|
43
|
+
Ribose.configure do |config|
|
44
|
+
config.api_token = ENV["RIBOSE_API_TOKEN"] || "RIBOSE_API_TOKEN"
|
45
|
+
config.user_email = ENV["RIBOSE_USER_EMAIL"] || "RIBOSE_USER_EMAIL"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe Ribose::Widget do
|
4
|
+
describe ".all" do
|
5
|
+
it "retrieves the list of widgets" do
|
6
|
+
stub_ribose_widget_list_api
|
7
|
+
widgets = Ribose::Widget.all
|
8
|
+
|
9
|
+
expect(widgets.first.id).not_to be_nil
|
10
|
+
expect(widgets.first.status).to eq("loaded")
|
11
|
+
expect(widgets.first.type).to eq("Widget::RssFeed")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe Ribose::Wiki do
|
4
|
+
describe ".all" do
|
5
|
+
it "retrieves the list of wiki pages" do
|
6
|
+
space_id = 123_456
|
7
|
+
|
8
|
+
stub_ribose_wiki_list_api(space_id)
|
9
|
+
wikis = Ribose::Wiki.all(space_id)
|
10
|
+
|
11
|
+
expect(wikis.count).to eq(2)
|
12
|
+
expect(wikis.first.name).to eq("Wiki Page One")
|
13
|
+
expect(wikis.last.name).to eq("Wiki Page Two")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe ".fetch" do
|
18
|
+
it "retrieves the details for a wiki page" do
|
19
|
+
wiki_id = 456_789
|
20
|
+
space_id = 123_456
|
21
|
+
|
22
|
+
stub_ribose_wiki_fetch_api(space_id, wiki_id)
|
23
|
+
wiki = Ribose::Wiki.fetch(space_id, wiki_id)
|
24
|
+
|
25
|
+
expect(wiki.name).to eq("Wiki Page One")
|
26
|
+
expect(wiki.history.current_ver).to eq(1)
|
27
|
+
expect(wiki.updater.name).to eq("John Doe")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe ".create" do
|
32
|
+
it "creates a new wiki page in space" do
|
33
|
+
space_id = 123_456
|
34
|
+
attributes = { name: "Wiki Page One" }
|
35
|
+
|
36
|
+
stub_ribose_wiki_create_api(space_id, attributes)
|
37
|
+
wiki = Ribose::Wiki.create(space_id, attributes)
|
38
|
+
|
39
|
+
expect(wiki.id).not_to be_nil
|
40
|
+
expect(wiki.name).to eq(attributes[:name])
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe ".update" do
|
45
|
+
it "updates a wiki with provided details" do
|
46
|
+
wiki_id = 456_789
|
47
|
+
space_id = 123_456
|
48
|
+
attributes = { name: "Wiki Page One" }
|
49
|
+
|
50
|
+
stub_ribose_wiki_update_api(space_id, wiki_id, attributes)
|
51
|
+
wiki = Ribose::Wiki.update(space_id, wiki_id, attributes)
|
52
|
+
|
53
|
+
expect(wiki.id).not_to be_nil
|
54
|
+
expect(wiki.name).to eq("Wiki Page One")
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe ".delete" do
|
59
|
+
it "deletes an existing space wiki page" do
|
60
|
+
wiki_id = 456_789
|
61
|
+
space_id = 123_456
|
62
|
+
|
63
|
+
stub_ribose_wiki_delete_api(space_id, wiki_id)
|
64
|
+
expect { Ribose::Wiki.delete(space_id, wiki_id) }.not_to raise_error
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|