ruby-lokalise-api 5.0.0 → 6.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (147) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -1
  3. data/README.md +7 -5
  4. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/base_request.rb +4 -4
  5. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/client.rb +24 -24
  6. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/base.rb +10 -10
  7. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/branch.rb +1 -1
  8. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/contributor.rb +1 -1
  9. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/custom_translation_status.rb +1 -1
  10. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/file.rb +1 -1
  11. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/key.rb +2 -2
  12. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/key_comment.rb +1 -1
  13. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/order.rb +1 -1
  14. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/payment_card.rb +1 -1
  15. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/project.rb +1 -1
  16. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/project_comment.rb +1 -1
  17. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/project_language.rb +1 -1
  18. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/queued_process.rb +1 -1
  19. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/screenshot.rb +1 -1
  20. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/segment.rb +1 -1
  21. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/snapshot.rb +1 -1
  22. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/system_language.rb +1 -1
  23. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/task.rb +1 -1
  24. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/team.rb +1 -1
  25. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/team_user.rb +1 -1
  26. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/team_user_group.rb +1 -1
  27. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/translation.rb +1 -1
  28. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/translation_provider.rb +1 -1
  29. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/webhook.rb +1 -1
  30. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/connection.rb +2 -2
  31. data/lib/ruby_lokalise_api/data/attributes.yml +235 -0
  32. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/error.rb +14 -14
  33. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/json_handler.rb +1 -1
  34. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/oauth2/auth.rb +2 -2
  35. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/oauth2/connection.rb +2 -2
  36. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/oauth2/request.rb +3 -3
  37. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/oauth2_client.rb +1 -1
  38. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/request.rb +3 -3
  39. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/base.rb +16 -8
  40. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/branch.rb +1 -1
  41. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/contributor.rb +1 -1
  42. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/custom_translation_status.rb +1 -1
  43. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/file.rb +2 -2
  44. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/key.rb +1 -1
  45. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/key_comment.rb +1 -1
  46. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/order.rb +1 -1
  47. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/payment_card.rb +1 -1
  48. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/project.rb +1 -1
  49. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/project_comment.rb +1 -1
  50. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/project_language.rb +1 -1
  51. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/queued_process.rb +1 -1
  52. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/screenshot.rb +1 -1
  53. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/segment.rb +1 -1
  54. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/snapshot.rb +2 -2
  55. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/system_language.rb +1 -1
  56. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/task.rb +1 -1
  57. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/team.rb +1 -1
  58. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/team_user.rb +1 -1
  59. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/team_user_billing_details.rb +1 -1
  60. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/team_user_group.rb +1 -1
  61. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/translation.rb +1 -1
  62. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/translation_provider.rb +1 -1
  63. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/webhook.rb +1 -1
  64. data/lib/ruby_lokalise_api/rest/branches.rb +69 -0
  65. data/lib/ruby_lokalise_api/rest/comments.rb +61 -0
  66. data/lib/ruby_lokalise_api/rest/contributors.rb +58 -0
  67. data/lib/ruby_lokalise_api/rest/custom_translation_statuses.rb +67 -0
  68. data/lib/ruby_lokalise_api/rest/files.rb +49 -0
  69. data/lib/ruby_lokalise_api/rest/keys.rb +79 -0
  70. data/lib/ruby_lokalise_api/rest/languages.rb +67 -0
  71. data/lib/ruby_lokalise_api/rest/orders.rb +37 -0
  72. data/lib/ruby_lokalise_api/rest/payment_cards.rb +43 -0
  73. data/lib/ruby_lokalise_api/rest/projects.rb +62 -0
  74. data/lib/ruby_lokalise_api/rest/queued_processes.rb +28 -0
  75. data/lib/ruby_lokalise_api/rest/screenshots.rb +58 -0
  76. data/lib/ruby_lokalise_api/rest/segments.rb +45 -0
  77. data/lib/ruby_lokalise_api/rest/snapshots.rb +47 -0
  78. data/lib/ruby_lokalise_api/rest/tasks.rb +58 -0
  79. data/lib/ruby_lokalise_api/rest/team_user_billing_details.rb +36 -0
  80. data/lib/ruby_lokalise_api/rest/team_user_groups.rb +109 -0
  81. data/lib/ruby_lokalise_api/rest/team_users.rb +48 -0
  82. data/lib/ruby_lokalise_api/rest/teams.rb +16 -0
  83. data/lib/ruby_lokalise_api/rest/translation_providers.rb +27 -0
  84. data/lib/ruby_lokalise_api/rest/translations.rb +39 -0
  85. data/lib/ruby_lokalise_api/rest/webhooks.rb +69 -0
  86. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/utils/attribute_helpers.rb +7 -7
  87. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/utils/endpoint_helpers.rb +1 -1
  88. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/utils/string_utils.rb +1 -1
  89. data/lib/ruby_lokalise_api/version.rb +5 -0
  90. data/lib/ruby_lokalise_api.rb +50 -0
  91. data/ruby-lokalise-api.gemspec +8 -7
  92. metadata +125 -157
  93. data/lib/ruby-lokalise-api/data/attributes.json +0 -259
  94. data/lib/ruby-lokalise-api/rest/branches.rb +0 -67
  95. data/lib/ruby-lokalise-api/rest/comments.rb +0 -59
  96. data/lib/ruby-lokalise-api/rest/contributors.rb +0 -56
  97. data/lib/ruby-lokalise-api/rest/custom_translation_statuses.rb +0 -65
  98. data/lib/ruby-lokalise-api/rest/files.rb +0 -36
  99. data/lib/ruby-lokalise-api/rest/keys.rb +0 -77
  100. data/lib/ruby-lokalise-api/rest/languages.rb +0 -65
  101. data/lib/ruby-lokalise-api/rest/orders.rb +0 -35
  102. data/lib/ruby-lokalise-api/rest/payment_cards.rb +0 -41
  103. data/lib/ruby-lokalise-api/rest/projects.rb +0 -60
  104. data/lib/ruby-lokalise-api/rest/queued_processes.rb +0 -26
  105. data/lib/ruby-lokalise-api/rest/screenshots.rb +0 -56
  106. data/lib/ruby-lokalise-api/rest/segments.rb +0 -43
  107. data/lib/ruby-lokalise-api/rest/snapshots.rb +0 -45
  108. data/lib/ruby-lokalise-api/rest/tasks.rb +0 -56
  109. data/lib/ruby-lokalise-api/rest/team_user_billing_details.rb +0 -34
  110. data/lib/ruby-lokalise-api/rest/team_user_group.rb +0 -107
  111. data/lib/ruby-lokalise-api/rest/team_users.rb +0 -46
  112. data/lib/ruby-lokalise-api/rest/teams.rb +0 -14
  113. data/lib/ruby-lokalise-api/rest/translation_providers.rb +0 -25
  114. data/lib/ruby-lokalise-api/rest/translations.rb +0 -37
  115. data/lib/ruby-lokalise-api/rest/webhooks.rb +0 -67
  116. data/lib/ruby-lokalise-api/version.rb +0 -5
  117. data/lib/ruby-lokalise-api.rb +0 -111
  118. data/spec/lib/ruby-lokalise-api/connection_spec.rb +0 -68
  119. data/spec/lib/ruby-lokalise-api/custom_json_parser_spec.rb +0 -81
  120. data/spec/lib/ruby-lokalise-api/error_spec.rb +0 -41
  121. data/spec/lib/ruby-lokalise-api/oauth2/auth_spec.rb +0 -73
  122. data/spec/lib/ruby-lokalise-api/rest/branches_spec.rb +0 -140
  123. data/spec/lib/ruby-lokalise-api/rest/comments_spec.rb +0 -118
  124. data/spec/lib/ruby-lokalise-api/rest/contributors_spec.rb +0 -132
  125. data/spec/lib/ruby-lokalise-api/rest/custom_translation_statuses_spec.rb +0 -131
  126. data/spec/lib/ruby-lokalise-api/rest/files_spec.rb +0 -66
  127. data/spec/lib/ruby-lokalise-api/rest/keys_spec.rb +0 -199
  128. data/spec/lib/ruby-lokalise-api/rest/languages_spec.rb +0 -134
  129. data/spec/lib/ruby-lokalise-api/rest/orders_spec.rb +0 -113
  130. data/spec/lib/ruby-lokalise-api/rest/payment_cards_spec.rb +0 -92
  131. data/spec/lib/ruby-lokalise-api/rest/projects_spec.rb +0 -150
  132. data/spec/lib/ruby-lokalise-api/rest/queued_processes_spec.rb +0 -57
  133. data/spec/lib/ruby-lokalise-api/rest/screenshots_spec.rb +0 -127
  134. data/spec/lib/ruby-lokalise-api/rest/segments_spec.rb +0 -106
  135. data/spec/lib/ruby-lokalise-api/rest/snapshots_spec.rb +0 -117
  136. data/spec/lib/ruby-lokalise-api/rest/tasks_spec.rb +0 -145
  137. data/spec/lib/ruby-lokalise-api/rest/team_user_billing_details_spec.rb +0 -48
  138. data/spec/lib/ruby-lokalise-api/rest/team_user_groups_spec.rb +0 -278
  139. data/spec/lib/ruby-lokalise-api/rest/team_users_spec.rb +0 -95
  140. data/spec/lib/ruby-lokalise-api/rest/teams_spec.rb +0 -25
  141. data/spec/lib/ruby-lokalise-api/rest/translation_providers_spec.rb +0 -48
  142. data/spec/lib/ruby-lokalise-api/rest/translations_spec.rb +0 -118
  143. data/spec/lib/ruby-lokalise-api/rest/webhooks_spec.rb +0 -126
  144. data/spec/lib/ruby-lokalise-api_spec.rb +0 -47
  145. data/spec/spec_helper.rb +0 -22
  146. data/spec/support/test_client.rb +0 -15
  147. data/spec/support/vcr.rb +0 -15
@@ -1,41 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe Lokalise::Error do
4
- include Lokalise::Request
5
-
6
- before { Lokalise.reset_client! }
7
-
8
- after { Lokalise.reset_client! }
9
-
10
- it 'raises a generic error when the code is unknown' do
11
- expect do
12
- VCR.use_cassette('error_unknown_code') do
13
- get 'projects', Lokalise.client('invalid')
14
- end
15
- end.to raise_error(described_class)
16
- end
17
-
18
- it 'handles an exception when the response does not contain an error key' do
19
- expect do
20
- VCR.use_cassette('error_no_error_key') do
21
- get 'projects', Lokalise.client('invalid')
22
- end
23
- end.to raise_error(Lokalise::Error::BadRequest)
24
- end
25
-
26
- it 'raises BadRequest when API token is invalid' do
27
- expect do
28
- VCR.use_cassette('error_invalid_token') do
29
- get 'projects', Lokalise.client('invalid')
30
- end
31
- end.to raise_error(Lokalise::Error::BadRequest)
32
- end
33
-
34
- it 'raises NotFound when the provided path cannot be found' do
35
- expect do
36
- VCR.use_cassette('error_not_found') do
37
- get 'invalid_path', test_client
38
- end
39
- end.to raise_error(Lokalise::Error::NotFound)
40
- end
41
- end
@@ -1,73 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe Lokalise::OAuth2::Auth do
4
- describe '#auth' do
5
- it 'returns auth code' do
6
- uri = auth_client.auth scope: 'read_projects'
7
- expect(uri).to include(described_class::BASE_URL.to_s)
8
- expect(uri).to include('auth?client_id=')
9
- expect(uri).to include('&scope=read_projects')
10
- end
11
-
12
- it 'allows to pass an array of scopes' do
13
- scopes = %w[write_projects write_team_groups write_tasks]
14
- uri = auth_client.auth scope: scopes
15
- expect(uri).to include(described_class::BASE_URL.to_s)
16
- expect(uri).to include('auth?client_id=')
17
- expect(uri).to include("&scope=#{scopes.join('+')}")
18
- end
19
-
20
- it 'allows to set redirect_uri' do
21
- uri = auth_client.auth scope: 'read_projects', redirect_uri: 'http://example.com/callback'
22
- expect(uri).to include(described_class::BASE_URL.to_s)
23
- expect(uri).to include('example.com%2Fcallback')
24
- end
25
-
26
- it 'allows to set state' do
27
- state = '123abc'
28
- uri = auth_client.auth scope: 'read_projects', state: state
29
- expect(uri).to include(described_class::BASE_URL.to_s)
30
- expect(uri).to include(state)
31
- end
32
- end
33
-
34
- describe '#token' do
35
- it 'returns an OAuth2 token' do
36
- resp = VCR.use_cassette('oauth2/token') do
37
- auth_client.token ENV['OAUTH2_CODE']
38
- end
39
- expect(resp['access_token']).not_to be_nil
40
- expect(resp['refresh_token']).not_to be_nil
41
- expect(resp['expires_in']).to eq(3600)
42
- expect(resp['token_type']).to eq('Bearer')
43
- end
44
-
45
- it 'raises an error when the code is invalid' do
46
- expect do
47
- VCR.use_cassette('oauth2/token_error') do
48
- auth_client.token 'incorrect_code'
49
- end
50
- end.to raise_error(Lokalise::Error::BadRequest)
51
- end
52
- end
53
-
54
- describe '#refresh' do
55
- it 'returns a refreshed OAuth2 token' do
56
- resp = VCR.use_cassette('oauth2/refresh') do
57
- auth_client.refresh ENV['OAUTH2_REFRESH_TOKEN']
58
- end
59
- expect(resp['access_token']).not_to be_nil
60
- expect(resp['refresh_token']).to be_nil
61
- expect(resp['expires_in']).to eq(3600)
62
- expect(resp['token_type']).to eq('Bearer')
63
- end
64
-
65
- it 'raises an error when the token is invalid' do
66
- expect do
67
- VCR.use_cassette('oauth2/refresh_error') do
68
- auth_client.refresh 'incorrect_token'
69
- end
70
- end.to raise_error(Lokalise::Error::BadRequest)
71
- end
72
- end
73
- end
@@ -1,140 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe Lokalise::Client do
4
- let(:project_id) { '803826145ba90b42d5d860.46800099' }
5
- let(:branch_id) { 41_302 }
6
-
7
- describe '#branches' do
8
- it 'returns all branches' do
9
- branches = VCR.use_cassette('all_branches') do
10
- test_client.branches project_id
11
- end.collection
12
-
13
- expect(branches.count).to eq(4)
14
- end
15
-
16
- it 'supports pagination' do
17
- branches = VCR.use_cassette('all_branches_pagination') do
18
- test_client.branches project_id, limit: 2, page: 2
19
- end
20
-
21
- expect(branches.collection.count).to eq(2)
22
- expect(branches.total_results).to eq(4)
23
- expect(branches.total_pages).to eq(2)
24
- expect(branches.results_per_page).to eq(2)
25
- expect(branches.current_page).to eq(2)
26
- expect(branches.collection.first.name).to eq('merge-me')
27
- end
28
- end
29
-
30
- specify '#branch' do
31
- branch = VCR.use_cassette('branch') do
32
- test_client.branch project_id, branch_id
33
- end
34
-
35
- expect(branch.branch_id).to eq(branch_id)
36
- expect(branch.name).to eq('ruby-branch')
37
- expect(branch.created_at).to eq('2019-10-30 14:24:41 (Etc/UTC)')
38
- expect(branch.created_at_timestamp).to eq(1_572_445_481)
39
- expect(branch.created_by).to eq(20_181)
40
- expect(branch.created_by_email).to eq('bodrovis@protonmail.com')
41
- end
42
-
43
- specify '#reload_data' do
44
- branch = VCR.use_cassette('branch') do
45
- test_client.branch project_id, branch_id
46
- end
47
-
48
- reloaded_branch = VCR.use_cassette('branch') do
49
- branch.reload_data
50
- end
51
-
52
- expect(reloaded_branch.branch_id).to eq(branch.branch_id)
53
- end
54
-
55
- specify '#create_branch' do
56
- branch = VCR.use_cassette('create_branch') do
57
- test_client.create_branch project_id, name: 'ruby-branch'
58
- end
59
-
60
- expect(branch.name).to eq('ruby-branch')
61
- end
62
-
63
- specify '#update_branch' do
64
- branch = VCR.use_cassette('update_branch') do
65
- test_client.update_branch project_id, branch_id, name: 'updated-ruby-branch'
66
- end
67
-
68
- expect(branch.name).to eq('updated-ruby-branch')
69
- end
70
-
71
- specify '#destroy_branch' do
72
- response = VCR.use_cassette('destroy_branch') do
73
- test_client.destroy_branch project_id, branch_id
74
- end
75
-
76
- expect(response['project_id']).to eq(project_id)
77
- expect(response['branch_deleted']).to eq(true)
78
- end
79
-
80
- specify '#merge_branch' do
81
- branch = VCR.use_cassette('create_branch_to_merge') do
82
- test_client.create_branch project_id, name: 'merge-me'
83
- end
84
-
85
- expect(branch.name).to eq('merge-me')
86
-
87
- branch_id = branch.branch_id
88
-
89
- response = VCR.use_cassette('merge_branch') do
90
- test_client.merge_branch project_id, branch_id, force_conflict_resolve_using: 'master'
91
- end
92
-
93
- expect(response['project_id']).to eq(project_id)
94
- expect(response['branch_merged']).to eq(true)
95
- expect(response['branch']['branch_id']).to eq(branch_id)
96
- expect(response['branch']['name']).to eq(branch.name)
97
- end
98
-
99
- context 'when branch methods are chained' do
100
- it 'supports merge' do
101
- branch = VCR.use_cassette('create_branch_to_merge2') do
102
- test_client.create_branch project_id, name: 'merge-me-plz'
103
- end
104
-
105
- expect(branch.name).to eq('merge-me-plz')
106
-
107
- branch_id = branch.branch_id
108
-
109
- response = VCR.use_cassette('merge_branch_chained') do
110
- branch.merge force_conflict_resolve_using: 'master'
111
- end
112
-
113
- expect(response['project_id']).to eq(project_id)
114
- expect(response['branch_merged']).to eq(true)
115
- expect(response['branch']['branch_id']).to eq(branch_id)
116
- expect(response['branch']['name']).to eq(branch.name)
117
- end
118
-
119
- it 'supports update and destroy' do
120
- branch = VCR.use_cassette('create_another_branch') do
121
- test_client.create_branch project_id, name: 'ruby-second-branch'
122
- end
123
-
124
- expect(branch.name).to eq('ruby-second-branch')
125
-
126
- branch = VCR.use_cassette('update_another_branch') do
127
- branch.update name: 'updated-ruby-second-branch'
128
- end
129
-
130
- expect(branch.name).to eq('updated-ruby-second-branch')
131
-
132
- response = VCR.use_cassette('destroy_another_branch') do
133
- branch.destroy
134
- end
135
-
136
- expect(response['project_id']).to eq(project_id)
137
- expect(response['branch_deleted']).to eq(true)
138
- end
139
- end
140
- end
@@ -1,118 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe Lokalise::Client do
4
- let(:project_id) { '803826145ba90b42d5d860.46800099' }
5
- let(:key_id) { 15_305_182 }
6
- let(:another_key_id) { 15_519_786 }
7
-
8
- describe '#comments' do
9
- it 'returns all comments' do
10
- comments = VCR.use_cassette('all_comments') do
11
- test_client.comments project_id, key_id
12
- end.collection
13
-
14
- expect(comments.count).to eq(3)
15
- end
16
-
17
- it 'supports pagination' do
18
- comments = VCR.use_cassette('all_comments_pagination') do
19
- test_client.comments project_id, key_id, limit: 1, page: 2
20
- end
21
-
22
- expect(comments.collection.count).to eq(1)
23
- expect(comments.total_results).to eq(3)
24
- expect(comments.total_pages).to eq(3)
25
- expect(comments.results_per_page).to eq(1)
26
- expect(comments.current_page).to eq(2)
27
- expect(comments.collection.first.comment).to eq('demo comment')
28
-
29
- expect(comments.next_page?).to eq(true)
30
- expect(comments.last_page?).to eq(false)
31
- expect(comments.prev_page?).to eq(true)
32
- expect(comments.first_page?).to eq(false)
33
-
34
- expect(comments.client).to be_an_instance_of(described_class)
35
- end
36
- end
37
-
38
- specify '#comment' do
39
- comment = VCR.use_cassette('comment') do
40
- test_client.comment project_id, another_key_id, '800746'
41
- end
42
-
43
- expect(comment.comment).to eq('rspec comment')
44
- expect(comment.comment_id).to eq(800_746)
45
- expect(comment.key_id).to eq(another_key_id)
46
- expect(comment.added_by).to eq(20_181)
47
- expect(comment.added_by_email).to eq('bodrovis@protonmail.com')
48
- expect(comment.added_at).to eq('2018-12-09 18:41:44 (Etc/UTC)')
49
- expect(comment.added_at_timestamp).to eq(1_544_380_904)
50
- end
51
-
52
- specify '#reload_data' do
53
- comment = VCR.use_cassette('comment') do
54
- test_client.comment project_id, another_key_id, '800746'
55
- end
56
-
57
- reloaded_comment = VCR.use_cassette('comment') do
58
- comment.reload_data
59
- end
60
-
61
- expect(reloaded_comment.key_id).to eq(comment.key_id)
62
- end
63
-
64
- specify '#create_comments' do
65
- comments = VCR.use_cassette('create_comments') do
66
- test_client.create_comments project_id, key_id, [
67
- {comment: 'demo comment'},
68
- {comment: 'from rspec'}
69
- ]
70
- end
71
-
72
- first_comment = comments.collection.first
73
- second_comment = comments.collection[1]
74
-
75
- expect(comments.project_id).to eq(project_id)
76
- expect(first_comment.comment).to eq('demo comment')
77
- expect(first_comment.key_id).to eq(key_id)
78
- expect(second_comment.comment).to eq('from rspec')
79
- expect(second_comment.key_id).to eq(key_id)
80
- end
81
-
82
- specify '#project_comments' do
83
- comments = VCR.use_cassette('project_comments') do
84
- test_client.project_comments project_id
85
- end
86
-
87
- comment = comments.collection.first
88
-
89
- expect(comments.total_results).to eq(3)
90
- expect(comment.comment).to eq('test')
91
- expect(comment.comment_id).to eq(767_938)
92
- end
93
-
94
- specify '#destroy_comment' do
95
- response = VCR.use_cassette('delete_comment') do
96
- test_client.destroy_comment project_id, key_id, 767_938
97
- end
98
- expect(response['project_id']).to eq(project_id)
99
- expect(response['comment_deleted']).to eq(true)
100
- end
101
-
102
- context 'when comment methods are chained' do
103
- it 'supports destroy' do
104
- comment = VCR.use_cassette('create_another_comment') do
105
- test_client.create_comments project_id, another_key_id, comment: 'chained comment'
106
- end.collection.first
107
-
108
- expect(comment.comment).to eq('chained comment')
109
-
110
- delete_response = VCR.use_cassette('delete_comment_chained') do
111
- comment.destroy
112
- end
113
-
114
- expect(delete_response['project_id']).to eq(project_id)
115
- expect(delete_response['comment_deleted']).to eq(true)
116
- end
117
- end
118
- end
@@ -1,132 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe Lokalise::Client do
4
- let(:project_id) { '803826145ba90b42d5d860.46800099' }
5
- let(:contributor_id) { 25_953 }
6
-
7
- describe '#contributors' do
8
- it 'returns all contributors' do
9
- contributors = VCR.use_cassette('all_contributors') do
10
- test_client.contributors project_id
11
- end.collection
12
-
13
- expect(contributors.count).to eq(2)
14
- expect(contributors.first.fullname).to eq('John Doe')
15
- end
16
-
17
- it 'supports pagination' do
18
- contributors = VCR.use_cassette('all_contributors_pagination') do
19
- test_client.contributors project_id, limit: 1, page: 2
20
- end
21
-
22
- expect(contributors.collection.count).to eq(1)
23
- expect(contributors.total_results).to eq(2)
24
- expect(contributors.total_pages).to eq(2)
25
- expect(contributors.results_per_page).to eq(1)
26
- expect(contributors.current_page).to eq(2)
27
-
28
- expect(contributors.next_page?).to eq(false)
29
- expect(contributors.last_page?).to eq(true)
30
- expect(contributors.prev_page?).to eq(true)
31
- expect(contributors.first_page?).to eq(false)
32
- end
33
- end
34
-
35
- specify '#contributor' do
36
- contributor = VCR.use_cassette('contributor') do
37
- test_client.contributor project_id, '20181'
38
- end
39
-
40
- expect(contributor.user_id).to eq(20_181)
41
- expect(contributor.email).to eq('bodrovis@protonmail.com')
42
- expect(contributor.fullname).to eq('Ilya B')
43
- expect(contributor.created_at).to eq('2018-08-21 15:35:25 (Etc/UTC)')
44
- expect(contributor.is_admin).to eq(true)
45
- expect(contributor.is_reviewer).to eq(true)
46
- expect(contributor.languages.first['lang_id']).to eq(803)
47
- expect(contributor.admin_rights.first).to eq('upload')
48
- expect(contributor.created_at_timestamp).to eq(1_534_865_725)
49
- end
50
-
51
- specify '#reload_data' do
52
- contributor = VCR.use_cassette('contributor') do
53
- test_client.contributor project_id, '20181'
54
- end
55
-
56
- reloaded_contributor = VCR.use_cassette('contributor') do
57
- contributor.reload_data
58
- end
59
-
60
- expect(reloaded_contributor.user_id).to eq(contributor.user_id)
61
- end
62
-
63
- specify '#create_contributors' do
64
- contributor = VCR.use_cassette('create_contributors') do
65
- test_client.create_contributors project_id,
66
- email: 'rspec@test.com',
67
- fullname: 'Rspec test',
68
- languages: [{
69
- lang_iso: 'en'
70
- },
71
- {
72
- lang_iso: 'ru'
73
- }]
74
- end.collection.first
75
-
76
- expect(contributor.fullname).to eq('Rspec test')
77
- expect(contributor.email).to eq('rspec@test.com')
78
- expect(contributor.languages[1]['lang_iso']).to eq('ru')
79
- end
80
-
81
- specify '#update_contributor' do
82
- contributor = VCR.use_cassette('update_contributor') do
83
- test_client.update_contributor project_id, contributor_id,
84
- languages: [{lang_iso: 'en'}]
85
- end
86
-
87
- expect(contributor.user_id).to eq(contributor_id)
88
- expect(contributor.languages[0]['lang_iso']).to eq('en')
89
- expect(contributor.languages.length).to eq(1)
90
- end
91
-
92
- specify '#destroy_contributor' do
93
- response = VCR.use_cassette('delete_contributor') do
94
- test_client.destroy_contributor project_id, contributor_id
95
- end
96
- expect(response['project_id']).to eq(project_id)
97
- expect(response['contributor_deleted']).to eq(true)
98
- end
99
-
100
- context 'when contributor methods are chained' do
101
- it 'supports update and destroy' do
102
- contributor = VCR.use_cassette('create_another_contributor') do
103
- test_client.create_contributors project_id,
104
- email: 'demo@test.com',
105
- fullname: 'chained',
106
- languages: [{lang_iso: 'en'}]
107
- end.collection.first
108
-
109
- expect(contributor.client.token).to eq(test_client.token)
110
- expect(contributor.fullname).to eq('chained')
111
-
112
- id = contributor.user_id
113
- path = contributor.path
114
-
115
- updated_contributor = VCR.use_cassette('update_contributor_chained') do
116
- contributor.update fullname: 'updated!'
117
- end
118
-
119
- expect(updated_contributor.client.token).to eq(test_client.token)
120
- expect(updated_contributor.fullname).to eq('updated!')
121
- expect(updated_contributor.user_id).to eq(id)
122
- expect(updated_contributor.path).to eq(path)
123
-
124
- delete_response = VCR.use_cassette('delete_contributor_chained') do
125
- updated_contributor.destroy
126
- end
127
-
128
- expect(delete_response['project_id']).to eq(project_id)
129
- expect(delete_response['contributor_deleted']).to eq(true)
130
- end
131
- end
132
- end
@@ -1,131 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe Lokalise::Client do
4
- let(:project_id) { '803826145ba90b42d5d860.46800099' }
5
- let(:status_id) { 128 }
6
- let(:new_status_id) { 126 }
7
-
8
- describe '#translation_statuses' do
9
- it 'returns all statuses' do
10
- statuses = VCR.use_cassette('all_translation_statuses') do
11
- test_client.translation_statuses project_id
12
- end.collection
13
-
14
- expect(statuses.count).to eq(3)
15
- expect(statuses.first.status_id).to eq(status_id)
16
- end
17
-
18
- it 'supports pagination' do
19
- statuses = VCR.use_cassette('all_translation_statuses_pagination') do
20
- test_client.translation_statuses project_id, limit: 1, page: 2
21
- end
22
-
23
- expect(statuses.collection.count).to eq(1)
24
- expect(statuses.total_results).to eq(3)
25
- expect(statuses.total_pages).to eq(3)
26
- expect(statuses.results_per_page).to eq(1)
27
- expect(statuses.current_page).to eq(2)
28
-
29
- expect(statuses.next_page?).to eq(true)
30
- expect(statuses.last_page?).to eq(false)
31
- expect(statuses.prev_page?).to eq(true)
32
- expect(statuses.first_page?).to eq(false)
33
- end
34
- end
35
-
36
- specify '#translation_status' do
37
- status = VCR.use_cassette('translation_status') do
38
- test_client.translation_status project_id, status_id
39
- end
40
-
41
- expect(status.status_id).to eq(status_id)
42
- expect(status.title).to eq('random')
43
- expect(status.color).to eq('#0079bf')
44
- end
45
-
46
- specify '#reload_data' do
47
- status = VCR.use_cassette('translation_status') do
48
- test_client.translation_status project_id, status_id
49
- end
50
-
51
- reloaded_status = VCR.use_cassette('translation_status') do
52
- status.reload_data
53
- end
54
-
55
- expect(reloaded_status.status_id).to eq(status.status_id)
56
- end
57
-
58
- specify '#create_translation_status' do
59
- title = 'Reviewed by doctors'
60
- color = '#f2d600'
61
- status = VCR.use_cassette('create_translation_status') do
62
- test_client.create_translation_status project_id,
63
- title: title,
64
- color: color
65
- end
66
-
67
- expect(status.title).to eq(title)
68
- expect(status.color).to eq(color)
69
- end
70
-
71
- specify '#update_translation_status' do
72
- title = 'Reviewed by rubyists'
73
- color = '#c377e0'
74
- status = VCR.use_cassette('update_translation_status') do
75
- test_client.update_translation_status project_id, new_status_id,
76
- title: title,
77
- color: color
78
- end
79
-
80
- expect(status.title).to eq(title)
81
- expect(status.color).to eq(color)
82
- end
83
-
84
- specify '#destroy_translation_status' do
85
- response = VCR.use_cassette('destroy_translation_status') do
86
- test_client.destroy_translation_status project_id, new_status_id
87
- end
88
-
89
- expect(response['project_id']).to eq(project_id)
90
- expect(response['custom_translation_status_deleted']).to eq(true)
91
- end
92
-
93
- specify '#translation_status_colors' do
94
- response = VCR.use_cassette('translation_status_colors') do
95
- test_client.translation_status_colors project_id
96
- end
97
-
98
- expect(response).to be_an(Array)
99
- expect(response).to include('#f2d600')
100
- end
101
-
102
- context 'when translation status methods are chained' do
103
- it 'supports update and destroy' do
104
- status = VCR.use_cassette('create_another_translation_status') do
105
- test_client.create_translation_status project_id,
106
- title: 'rspec',
107
- color: '#c377e0'
108
- end
109
-
110
- expect(status.title).to eq('rspec')
111
- expect(status.color).to eq('#c377e0')
112
-
113
- status = VCR.use_cassette('update_another_translation_status') do
114
- status.update(
115
- title: 'updated rspec',
116
- color: '#0079bf'
117
- )
118
- end
119
-
120
- expect(status.title).to eq('updated rspec')
121
- expect(status.color).to eq('#0079bf')
122
-
123
- response = VCR.use_cassette('delete_another_translation_status') do
124
- status.destroy
125
- end
126
-
127
- expect(response['project_id']).to eq(project_id)
128
- expect(response['custom_translation_status_deleted']).to eq(true)
129
- end
130
- end
131
- end