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,150 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe Lokalise::Client do
4
- let(:new_project_id) { '572222075c0953fd70d492.30502628' }
5
-
6
- describe '#projects' do
7
- it 'returns all projects' do
8
- projects = VCR.use_cassette('all_projects') do
9
- test_client.projects
10
- end.collection
11
- project = projects.first
12
-
13
- expect(projects.count).to eq(5)
14
- expect(project.name).to eq('demo phoenix')
15
- end
16
-
17
- it 'supports pagination' do
18
- projects = VCR.use_cassette('all_projects_pagination') do
19
- test_client.projects limit: 1, page: 2
20
- end
21
-
22
- expect(projects.collection.count).to eq(1)
23
- expect(projects.total_results).to eq(5)
24
- expect(projects.total_pages).to eq(5)
25
- expect(projects.results_per_page).to eq(1)
26
- expect(projects.current_page).to eq(2)
27
-
28
- expect(projects.next_page?).to eq(true)
29
- expect(projects.last_page?).to eq(false)
30
- expect(projects.prev_page?).to eq(true)
31
- expect(projects.first_page?).to eq(false)
32
- end
33
- end
34
-
35
- specify '#project' do
36
- project = VCR.use_cassette('project') do
37
- test_client.project '803826145ba90b42d5d860.46800099'
38
- end
39
-
40
- expect(project.project_id).to eq('803826145ba90b42d5d860.46800099')
41
- expect(project.name).to eq('demo phoenix')
42
- expect(project.team_id).to eq(176_692)
43
- expect(project.description).to eq('')
44
- expect(project.created_at).to eq('2018-09-24 16:05:22 (Etc/UTC)')
45
- expect(project.created_by).to eq(20_181)
46
- expect(project.created_by_email).to eq('bodrovis@protonmail.com')
47
- expect(project.created_at_timestamp).to eq(1_537_805_122)
48
- expect(project.base_language_id).to eq(640)
49
- expect(project.base_language_iso).to eq('en')
50
- expect(project.settings['per_platform_key_names']).to eq(false)
51
- expect(project.statistics['progress_total']).to eq(18)
52
- end
53
-
54
- specify '#reload_data' do
55
- project = VCR.use_cassette('project') do
56
- test_client.project '803826145ba90b42d5d860.46800099'
57
- end
58
-
59
- reloaded_project = VCR.use_cassette('project') do
60
- project.reload_data
61
- end
62
-
63
- expect(reloaded_project.project_id).to eq(project.project_id)
64
- end
65
-
66
- specify '#create_project' do
67
- project = VCR.use_cassette('new_project') do
68
- test_client.create_project name: 'rspec proj', description: 'demo project for rspec'
69
- end
70
-
71
- expect(project.name).to eq('rspec proj')
72
- expect(project.description).to eq('demo project for rspec')
73
- expect(project.team_id).to eq(176_692)
74
- end
75
-
76
- context 'with OAuth 2 token' do
77
- it 'creates a project' do
78
- name = 'OAuth 2 project'
79
- description = 'Via OAuth 2'
80
- project = VCR.use_cassette('oauth2/new_project') do
81
- test_oauth2_client.create_project name: name, description: description
82
- end
83
-
84
- expect(project.name).to eq(name)
85
- expect(project.description).to eq(description)
86
- end
87
- end
88
-
89
- specify '#update_project' do
90
- project = VCR.use_cassette('update_project') do
91
- test_client.update_project new_project_id,
92
- name: 'rspec proj updated', description: 'updated project for rspec'
93
- end
94
-
95
- expect(project.name).to eq('rspec proj updated')
96
- expect(project.description).to eq('updated project for rspec')
97
- expect(project.team_id).to eq(176_692)
98
- end
99
-
100
- specify '#empty_project' do
101
- response = VCR.use_cassette('empty_project') do
102
- test_client.empty_project new_project_id
103
- end
104
-
105
- expect(response['project_id']).to eq(new_project_id)
106
- expect(response['keys_deleted']).to eq(true)
107
- end
108
-
109
- specify '#destroy_project' do
110
- response = VCR.use_cassette('delete_project') do
111
- test_client.destroy_project new_project_id
112
- end
113
- expect(response['project_id']).to eq(new_project_id)
114
- expect(response['project_deleted']).to eq(true)
115
- end
116
-
117
- context 'when project methods are chained' do
118
- it 'supports update, empty, and destroy' do
119
- project = VCR.use_cassette('create_another_project') do
120
- test_client.create_project name: 'chained proj'
121
- end
122
-
123
- expect(project.name).to eq('chained proj')
124
-
125
- path = project.path
126
-
127
- updated_project = VCR.use_cassette('update_project_chained') do
128
- project.update name: 'updated!'
129
- end
130
-
131
- expect(updated_project.client.token).to eq(test_client.token)
132
- expect(updated_project.name).to eq('updated!')
133
- expect(updated_project.path).to eq(path)
134
-
135
- empty_response = VCR.use_cassette('empty_project_chained') do
136
- updated_project.empty
137
- end
138
-
139
- expect(empty_response['project_id']).to eq(updated_project.project_id)
140
- expect(empty_response['keys_deleted']).to eq(true)
141
-
142
- delete_response = VCR.use_cassette('delete_project_chained') do
143
- updated_project.destroy
144
- end
145
-
146
- expect(delete_response['project_id']).to eq(updated_project.project_id)
147
- expect(delete_response['project_deleted']).to eq(true)
148
- end
149
- end
150
- end
@@ -1,57 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe Lokalise::Client do
4
- let(:project_id) { '803826145ba90b42d5d860.46800099' }
5
- let(:process_id) { '3b943469e6b3e324b5bdad639b122a623e6e7a1a' }
6
- let(:queued_process_id) { '85c42bf5eff44648ca2f01f9db67b7d306a2f282' }
7
-
8
- describe '#queued_processes' do
9
- it 'returns all queued processes' do
10
- processes = VCR.use_cassette('all_queued_processes') do
11
- test_client.queued_processes project_id
12
- end
13
-
14
- expect(processes.branch).to eq('master')
15
- processes = processes.collection
16
- expect(processes.count).to eq(8)
17
- expect(processes.first.process_id).to eq(process_id)
18
- end
19
- end
20
-
21
- specify '#queued_process' do
22
- process = VCR.use_cassette('queued_process') do
23
- test_client.queued_process project_id, process_id
24
- end
25
-
26
- expect(process.branch).to eq('master')
27
- expect(process.process_id).to eq(process_id)
28
- expect(process.type).to eq('file-import')
29
- expect(process.status).to eq('finished')
30
- expect(process.message).to eq('')
31
- expect(process.created_by).to eq(20_181)
32
- expect(process.created_by_email).to eq('bodrovis@protonmail.com')
33
- expect(process.created_at).to eq('2020-05-13 11:24:37 (Etc/UTC)')
34
- expect(process.created_at_timestamp).to eq(1_589_369_077)
35
- files = process.details['files']
36
- expect(files.count).to eq(1)
37
- expect(files[0]['status']).to eq('finished')
38
- expect(files[0]['name_original']).to eq('test_async.json')
39
- end
40
-
41
- describe 'process status check' do
42
- specify '#reload_data' do
43
- queued_process = VCR.use_cassette('upload_file_status') do
44
- test_client.queued_process project_id, queued_process_id
45
- end
46
-
47
- expect(queued_process.status).to eq('finished')
48
-
49
- reloaded_process = VCR.use_cassette('upload_file_queued_reload') do
50
- queued_process.reload_data
51
- end
52
-
53
- expect(reloaded_process.process_id).to eq(queued_process.process_id)
54
- expect(reloaded_process.status).to eq('finished')
55
- end
56
- end
57
- end
@@ -1,127 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe Lokalise::Client do
4
- let(:project_id) { '803826145ba90b42d5d860.46800099' }
5
- let(:screenshot_id) { 115_185 }
6
-
7
- describe '#screenshots' do
8
- it 'returns all screenshots' do
9
- screenshots = VCR.use_cassette('all_screenshots') do
10
- test_client.screenshots project_id
11
- end.collection
12
-
13
- expect(screenshots.count).to eq(1)
14
- end
15
-
16
- it 'supports pagination' do
17
- screenshots = VCR.use_cassette('all_screenshots_pagination') do
18
- test_client.screenshots project_id, limit: 1, page: 1
19
- end
20
-
21
- expect(screenshots.collection.count).to eq(1)
22
- expect(screenshots.total_results).to eq(1)
23
- expect(screenshots.total_pages).to eq(1)
24
- expect(screenshots.results_per_page).to eq(1)
25
- expect(screenshots.current_page).to eq(1)
26
- end
27
- end
28
-
29
- specify '#screenshot' do
30
- screenshot = VCR.use_cassette('screenshot') do
31
- test_client.screenshot project_id, screenshot_id
32
- end
33
-
34
- expect(screenshot.screenshot_id).to eq(screenshot_id)
35
- expect(screenshot.key_ids).to eq([])
36
- expect(screenshot.url).to include('amazonaws.com')
37
- expect(screenshot.title).to eq('rspec screen')
38
- expect(screenshot.description).to eq('')
39
- expect(screenshot.screenshot_tags).to eq([])
40
- expect(screenshot.width).to eq(125)
41
- expect(screenshot.height).to eq(32)
42
- end
43
-
44
- specify '#reload_data' do
45
- screenshot = VCR.use_cassette('screenshot') do
46
- test_client.screenshot project_id, screenshot_id
47
- end
48
-
49
- reloaded_screenshot = VCR.use_cassette('screenshot') do
50
- screenshot.reload_data
51
- end
52
-
53
- expect(reloaded_screenshot.screenshot_id).to eq(screenshot.screenshot_id)
54
- end
55
-
56
- specify '#create_screenshots' do
57
- screenshot_from_file do |file|
58
- screenshot = VCR.use_cassette('create_screenshots') do
59
- test_client.create_screenshots project_id, data: file.read, title: 'rspec screen'
60
- end.collection.first
61
-
62
- expect(screenshot.title).to eq('rspec screen')
63
- expect(screenshot.url).to include('amazonaws.com')
64
- end
65
- end
66
-
67
- specify '#update_screenshot' do
68
- screenshot = VCR.use_cassette('update_screenshot') do
69
- test_client.update_screenshot project_id, screenshot_id, tags: %w[demo rspec],
70
- description: 'demo desc'
71
- end
72
-
73
- expect(screenshot.screenshot_id).to eq(screenshot_id)
74
- expect(screenshot.screenshot_tags).to eq(%w[demo rspec])
75
- expect(screenshot.description).to eq('demo desc')
76
- end
77
-
78
- specify '#destroy_screenshot' do
79
- response = VCR.use_cassette('delete_screenshot') do
80
- test_client.destroy_screenshot project_id, screenshot_id
81
- end
82
- expect(response['project_id']).to eq(project_id)
83
- expect(response['screenshot_deleted']).to eq(true)
84
- end
85
-
86
- context 'when screenshot methods are chained' do
87
- it 'supports update and destroy' do
88
- screenshot = screenshot_from_file do |file|
89
- VCR.use_cassette('create_another_screenshot') do
90
- test_client.create_screenshots project_id, data: file.read, title: 'chained screen'
91
- end.collection.first
92
- end
93
-
94
- expect(screenshot.client.token).to eq(test_client.token)
95
- expect(screenshot.title).to eq('chained screen')
96
-
97
- path = screenshot.path
98
-
99
- updated_screenshot = VCR.use_cassette('update_screenshot_chained') do
100
- screenshot.update title: 'updated!'
101
- end
102
-
103
- expect(updated_screenshot.client.token).to eq(test_client.token)
104
- expect(updated_screenshot.title).to eq('updated!')
105
- expect(updated_screenshot.screenshot_id).to eq(screenshot.screenshot_id)
106
- expect(updated_screenshot.path).to eq(path)
107
-
108
- delete_response = VCR.use_cassette('delete_screenshot_chained') do
109
- updated_screenshot.destroy
110
- end
111
-
112
- expect(delete_response['project_id']).to eq(project_id)
113
- expect(delete_response['screenshot_deleted']).to eq(true)
114
- end
115
- end
116
- end
117
-
118
- def screenshot_from_file
119
- file = File.open File.expand_path('spec/fixtures/screenshot_base64.txt')
120
- begin
121
- yield file
122
- rescue StandardError => e
123
- puts e
124
- ensure
125
- file.close
126
- end
127
- end
@@ -1,106 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe Lokalise::Client do
4
- let(:project_id) { '39066161618d4ecb9fdc12.00274309' }
5
- let(:key_id) { 129_358_815 }
6
-
7
- describe '#segments' do
8
- it 'returns all segments for a key under lang_iso' do
9
- segments = VCR.use_cassette('all_key_segments') do
10
- test_client.segments project_id, key_id, 'en'
11
- end.collection
12
-
13
- expect(segments.count).to eq(4)
14
- expect(segments.first.value).to eq('Hello!')
15
- end
16
- end
17
-
18
- describe '#segment' do
19
- it 'returns a single segment' do
20
- lang_iso = 'en'
21
- segment_number = 2
22
-
23
- segment = VCR.use_cassette('key_segment') do
24
- test_client.segment project_id, key_id, lang_iso, segment_number
25
- end
26
-
27
- expect(segment.key_id).to eq(key_id)
28
- expect(segment.segment_number).to eq(segment_number)
29
- expect(segment.language_iso).to eq(lang_iso)
30
- expect(segment.modified_at).to eq('2021-11-22 16:46:50 (Etc/UTC)')
31
- expect(segment.modified_at_timestamp).to eq(1_637_599_610)
32
- expect(segment.modified_by).to eq(20_181)
33
- expect(segment.modified_by_email).to eq('bodrovis@protonmail.com')
34
- expect(segment.value).to eq('This is just a simple text.')
35
- expect(segment.is_fuzzy).to eq(false)
36
- expect(segment.is_reviewed).to eq(false)
37
- expect(segment.reviewed_by).to eq(0)
38
- expect(segment.words).to eq(6)
39
- expect(segment.custom_translation_statuses.first['color']).to eq('#61bd4f')
40
- end
41
-
42
- it 'allows to pass params' do
43
- lang_iso = 'en'
44
- segment_number = 2
45
-
46
- segment = VCR.use_cassette('key_segment_params') do
47
- test_client.segment project_id, key_id, lang_iso, segment_number, disable_references: '1'
48
- end
49
-
50
- expect(segment.segment_number).to eq(segment_number)
51
- expect(segment.value).to eq('This is just a simple text.')
52
- expect(segment.language_iso).to eq(lang_iso)
53
- end
54
- end
55
-
56
- specify '#update_segment' do
57
- lang_iso = 'en'
58
- segment_number = 3
59
-
60
- segment = VCR.use_cassette('update_key_segment') do
61
- test_client.update_segment project_id, key_id, lang_iso, segment_number,
62
- value: 'Updated via API',
63
- is_reviewed: true
64
- end
65
-
66
- expect(segment.segment_number).to eq(segment_number)
67
- expect(segment.value).to eq('Updated via API')
68
- expect(segment.language_iso).to eq(lang_iso)
69
- end
70
-
71
- context 'when segment methods are chained' do
72
- specify '#reload_data' do
73
- lang_iso = 'en'
74
- segment_number = 2
75
-
76
- segment = VCR.use_cassette('key_segment') do
77
- test_client.segment project_id, key_id, lang_iso, segment_number
78
- end
79
-
80
- reloaded_segment = VCR.use_cassette('reload_key_segment') do
81
- segment.reload_data
82
- end
83
-
84
- expect(reloaded_segment.segment_number).to eq(segment_number)
85
- expect(reloaded_segment.key_id).to eq(key_id)
86
- end
87
-
88
- specify '#update' do
89
- lang_iso = 'en'
90
- segment_number = 4
91
-
92
- segment = VCR.use_cassette('another_key_segment') do
93
- test_client.segment project_id, key_id, lang_iso, segment_number
94
- end
95
-
96
- updated_segment = VCR.use_cassette('update_key_segment_chained') do
97
- segment.update value: 'Chain Updated',
98
- is_fuzzy: true
99
- end
100
-
101
- expect(updated_segment.segment_number).to eq(segment_number)
102
- expect(updated_segment.is_fuzzy).to eq(true)
103
- expect(updated_segment.value).to eq('Chain Updated')
104
- end
105
- end
106
- end
@@ -1,117 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe Lokalise::Client do
4
- let(:project_id) { '803826145ba90b42d5d860.46800099' }
5
- let(:snapshot_id) { 27_881 }
6
-
7
- describe '#snapshots' do
8
- it 'returns all snapshots' do
9
- snapshots = VCR.use_cassette('all_snapshots') do
10
- test_client.snapshots project_id
11
- end.collection
12
-
13
- snapshot = snapshots.first
14
-
15
- expect(snapshots.count).to eq(1)
16
- expect(snapshot.title).to eq('test rspec')
17
- expect(snapshot.snapshot_id).to eq(27_882)
18
- expect(snapshot.created_at).to eq('2018-12-10 17:02:04 (Etc/UTC)')
19
- expect(snapshot.created_by).to eq(20_181)
20
- expect(snapshot.created_by_email).to eq('bodrovis@protonmail.com')
21
- expect(snapshot.created_at_timestamp).to eq(1_544_461_324)
22
- end
23
-
24
- it 'supports pagination' do
25
- snapshots = VCR.use_cassette('all_snapshots_pagination') do
26
- test_client.snapshots project_id, limit: 1, page: 2
27
- end
28
-
29
- expect(snapshots.collection.count).to eq(1)
30
- expect(snapshots.total_results).to eq(2)
31
- expect(snapshots.total_pages).to eq(2)
32
- expect(snapshots.results_per_page).to eq(1)
33
- expect(snapshots.current_page).to eq(2)
34
-
35
- expect(snapshots.next_page?).to eq(false)
36
- expect(snapshots.last_page?).to eq(true)
37
- expect(snapshots.prev_page?).to eq(true)
38
- expect(snapshots.first_page?).to eq(false)
39
- end
40
- end
41
-
42
- specify '#create_snapshot' do
43
- snapshot = VCR.use_cassette('create_snapshot') do
44
- test_client.create_snapshot project_id, title: 'test rspec'
45
- end
46
-
47
- expect(snapshot.title).to eq('test rspec')
48
- end
49
-
50
- specify '#restore_snapshot' do
51
- project = VCR.use_cassette('restore_snapshot') do
52
- test_client.restore_snapshot project_id, snapshot_id
53
- end
54
-
55
- expect(project.name).to eq('demo phoenix copy')
56
- expect(project.created_by_email).to eq('bodrovis@protonmail.com')
57
- # Restore creates a new copy of the project!
58
- expect(project.project_id).not_to eq(project_id)
59
- end
60
-
61
- specify '#destroy_snapshot' do
62
- response = VCR.use_cassette('delete_snapshot') do
63
- test_client.destroy_snapshot project_id, snapshot_id
64
- end
65
-
66
- expect(response['project_id']).to eq(project_id)
67
- expect(response['snapshot_deleted']).to eq(true)
68
- end
69
-
70
- context 'when snapshot methods are chained' do
71
- it 'allows restored project to receive chained methods' do
72
- snapshot = VCR.use_cassette('create_snapshot_for_chained') do
73
- test_client.create_snapshot project_id, title: 'chained rspec snap'
74
- end
75
-
76
- new_project = VCR.use_cassette('restore_snapshot_for_chained') do
77
- snapshot.restore
78
- end
79
-
80
- updated_project = VCR.use_cassette('restored_updated_project') do
81
- new_project.update name: 'Restored and updated'
82
- end
83
-
84
- expect(updated_project.client.token).to eq(test_client.token)
85
- expect(updated_project.name).to eq('Restored and updated')
86
- expect(updated_project.project_id).to eq(new_project.project_id)
87
-
88
- response = VCR.use_cassette('delete_restored_project') do
89
- updated_project.destroy
90
- end
91
-
92
- expect(response['project_id']).to eq(updated_project.project_id)
93
- expect(response['project_deleted']).to eq(true)
94
- end
95
-
96
- it 'supports destroy and restore' do
97
- snapshot = VCR.use_cassette('create_another_snapshot') do
98
- test_client.create_snapshot project_id, title: 'chained'
99
- end
100
-
101
- expect(snapshot.title).to eq('chained')
102
-
103
- restored_project = VCR.use_cassette('restore_snapshot_chained') do
104
- snapshot.restore
105
- end
106
-
107
- expect(restored_project.name).to eq('demo phoenix copy')
108
-
109
- delete_response = VCR.use_cassette('delete_snapshot_chained') do
110
- snapshot.destroy
111
- end
112
-
113
- expect(delete_response['project_id']).to eq(project_id)
114
- expect(delete_response['snapshot_deleted']).to eq(true)
115
- end
116
- end
117
- end