ruby-lokalise-api 2.9.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/.github/CODE_OF_CONDUCT.md +1 -1
  3. data/.github/CONTRIBUTING.md +9 -2
  4. data/CHANGELOG.md +1 -75
  5. data/LICENSE +9 -18
  6. data/README.md +18 -1734
  7. data/lib/ruby-lokalise-api.rb +2 -0
  8. data/lib/ruby-lokalise-api/client.rb +16 -4
  9. data/lib/ruby-lokalise-api/collections/base.rb +5 -3
  10. data/lib/ruby-lokalise-api/collections/queued_process.rb +15 -0
  11. data/lib/ruby-lokalise-api/connection.rb +1 -1
  12. data/lib/ruby-lokalise-api/data/attributes.json +29 -13
  13. data/lib/ruby-lokalise-api/request.rb +8 -1
  14. data/lib/ruby-lokalise-api/resources/base.rb +55 -25
  15. data/lib/ruby-lokalise-api/resources/branch.rb +1 -1
  16. data/lib/ruby-lokalise-api/resources/contributor.rb +1 -1
  17. data/lib/ruby-lokalise-api/resources/custom_translation_status.rb +1 -1
  18. data/lib/ruby-lokalise-api/resources/file.rb +3 -1
  19. data/lib/ruby-lokalise-api/resources/key.rb +1 -1
  20. data/lib/ruby-lokalise-api/resources/key_comment.rb +1 -1
  21. data/lib/ruby-lokalise-api/resources/order.rb +2 -0
  22. data/lib/ruby-lokalise-api/resources/payment_card.rb +1 -1
  23. data/lib/ruby-lokalise-api/resources/project.rb +2 -2
  24. data/lib/ruby-lokalise-api/resources/project_language.rb +1 -1
  25. data/lib/ruby-lokalise-api/resources/queued_process.rb +18 -0
  26. data/lib/ruby-lokalise-api/resources/screenshot.rb +1 -1
  27. data/lib/ruby-lokalise-api/resources/snapshot.rb +3 -1
  28. data/lib/ruby-lokalise-api/resources/task.rb +1 -1
  29. data/lib/ruby-lokalise-api/resources/team_user.rb +1 -1
  30. data/lib/ruby-lokalise-api/resources/team_user_group.rb +2 -1
  31. data/lib/ruby-lokalise-api/resources/translation.rb +1 -1
  32. data/lib/ruby-lokalise-api/resources/translation_provider.rb +3 -0
  33. data/lib/ruby-lokalise-api/resources/webhook.rb +11 -3
  34. data/lib/ruby-lokalise-api/rest/comments.rb +5 -5
  35. data/lib/ruby-lokalise-api/rest/contributors.rb +5 -5
  36. data/lib/ruby-lokalise-api/rest/custom_translation_statuses.rb +6 -6
  37. data/lib/ruby-lokalise-api/rest/files.rb +3 -3
  38. data/lib/ruby-lokalise-api/rest/keys.rb +7 -7
  39. data/lib/ruby-lokalise-api/rest/languages.rb +6 -6
  40. data/lib/ruby-lokalise-api/rest/payment_cards.rb +3 -3
  41. data/lib/ruby-lokalise-api/rest/projects.rb +6 -6
  42. data/lib/ruby-lokalise-api/rest/queued_processes.rb +26 -0
  43. data/lib/ruby-lokalise-api/rest/screenshots.rb +5 -5
  44. data/lib/ruby-lokalise-api/rest/snapshots.rb +4 -4
  45. data/lib/ruby-lokalise-api/rest/tasks.rb +5 -5
  46. data/lib/ruby-lokalise-api/rest/team_user_group.rb +4 -4
  47. data/lib/ruby-lokalise-api/rest/team_users.rb +4 -4
  48. data/lib/ruby-lokalise-api/rest/teams.rb +1 -1
  49. data/lib/ruby-lokalise-api/rest/translation_providers.rb +2 -2
  50. data/lib/ruby-lokalise-api/rest/translations.rb +3 -3
  51. data/lib/ruby-lokalise-api/rest/webhooks.rb +16 -5
  52. data/lib/ruby-lokalise-api/utils/attribute_helpers.rb +11 -6
  53. data/lib/ruby-lokalise-api/version.rb +1 -1
  54. data/ruby-lokalise-api.gemspec +7 -7
  55. data/spec/lib/ruby-lokalise-api/custom_json_parser_spec.rb +4 -4
  56. data/spec/lib/ruby-lokalise-api/error_spec.rb +8 -0
  57. data/spec/lib/ruby-lokalise-api/rest/branches_spec.rb +12 -0
  58. data/spec/lib/ruby-lokalise-api/rest/comments_spec.rb +12 -0
  59. data/spec/lib/ruby-lokalise-api/rest/contributors_spec.rb +12 -0
  60. data/spec/lib/ruby-lokalise-api/rest/custom_translation_statuses_spec.rb +12 -0
  61. data/spec/lib/ruby-lokalise-api/rest/files_spec.rb +17 -9
  62. data/spec/lib/ruby-lokalise-api/rest/keys_spec.rb +38 -20
  63. data/spec/lib/ruby-lokalise-api/rest/languages_spec.rb +12 -0
  64. data/spec/lib/ruby-lokalise-api/rest/orders_spec.rb +12 -0
  65. data/spec/lib/ruby-lokalise-api/rest/payment_cards_spec.rb +19 -5
  66. data/spec/lib/ruby-lokalise-api/rest/projects_spec.rb +12 -0
  67. data/spec/lib/ruby-lokalise-api/rest/queued_processes_spec.rb +57 -0
  68. data/spec/lib/ruby-lokalise-api/rest/screenshots_spec.rb +12 -0
  69. data/spec/lib/ruby-lokalise-api/rest/snapshots_spec.rb +25 -0
  70. data/spec/lib/ruby-lokalise-api/rest/tasks_spec.rb +20 -7
  71. data/spec/lib/ruby-lokalise-api/rest/team_user_groups_spec.rb +84 -0
  72. data/spec/lib/ruby-lokalise-api/rest/team_users_spec.rb +13 -0
  73. data/spec/lib/ruby-lokalise-api/rest/translation_providers_spec.rb +5 -0
  74. data/spec/lib/ruby-lokalise-api/rest/translations_spec.rb +12 -0
  75. data/spec/lib/ruby-lokalise-api/rest/webhooks_spec.rb +50 -0
  76. metadata +25 -20
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Lokalise
4
- VERSION = '2.9.0'
4
+ VERSION = '4.0.0'
5
5
  end
@@ -10,9 +10,9 @@ Gem::Specification.new do |spec|
10
10
  spec.summary = 'Ruby interface to the Lokalise API'
11
11
  spec.description = 'Opinionated Ruby client for the Lokalise platform API allowing to work with translations, projects, users and other resources as with Ruby objects.'
12
12
  spec.homepage = 'https://github.com/lokalise/ruby-lokalise-api'
13
- spec.license = 'MIT'
13
+ spec.license = 'BSD-3-Clause'
14
14
  spec.platform = Gem::Platform::RUBY
15
- spec.required_ruby_version = '>= 2.4.0'
15
+ spec.required_ruby_version = '>= 2.5.0'
16
16
 
17
17
  spec.files = Dir['README.md', 'LICENSE',
18
18
  'CHANGELOG.md', 'lib/**/*.rb', 'lib/ruby-lokalise-api/data/attributes.json',
@@ -24,16 +24,16 @@ Gem::Specification.new do |spec|
24
24
 
25
25
  spec.add_dependency 'addressable', '~> 2.5'
26
26
  spec.add_dependency 'faraday', '~> 1.0'
27
- spec.add_dependency 'json', '~> 2.3'
27
+ spec.add_dependency 'json', '>= 1.8.0'
28
28
 
29
29
  spec.add_development_dependency 'codecov', '~> 0.1'
30
30
  spec.add_development_dependency 'dotenv', '~> 2.5'
31
- spec.add_development_dependency 'oj', '~> 3.8'
31
+ spec.add_development_dependency 'oj', '~> 3.10'
32
32
  spec.add_development_dependency 'rake', '~> 13.0'
33
33
  spec.add_development_dependency 'rspec', '~> 3.6'
34
- spec.add_development_dependency 'rubocop', '~> 0.60'
34
+ spec.add_development_dependency 'rubocop', '~> 1.6'
35
35
  spec.add_development_dependency 'rubocop-performance', '~> 1.5'
36
- spec.add_development_dependency 'rubocop-rspec', '~> 1.37'
36
+ spec.add_development_dependency 'rubocop-rspec', '~> 2.0'
37
37
  spec.add_development_dependency 'simplecov', '~> 0.16'
38
- spec.add_development_dependency 'vcr', '~> 5.0'
38
+ spec.add_development_dependency 'vcr', '~> 6.0'
39
39
  end
@@ -27,7 +27,7 @@ RSpec.describe Lokalise::JsonHandler do
27
27
  '{":name":"rspec proj",":description":"demo project for rspec"}'
28
28
  end
29
29
 
30
- # rubocop:disable RSpec/LeakyConstantDeclaration
30
+ # rubocop:disable RSpec/LeakyConstantDeclaration, Lint/ConstantDefinitionInBlock
31
31
  before do
32
32
  module Lokalise
33
33
  module JsonHandler
@@ -55,10 +55,10 @@ RSpec.describe Lokalise::JsonHandler do
55
55
  end
56
56
  end
57
57
  end
58
- # rubocop:enable RSpec/LeakyConstantDeclaration
58
+ # rubocop:enable RSpec/LeakyConstantDeclaration, Lint/ConstantDefinitionInBlock
59
59
 
60
60
  it 'allows to customize #load' do
61
- expect(Oj).to receive(:load).and_return(loaded_json)
61
+ allow(Oj).to receive(:load).and_return(loaded_json)
62
62
  expect(JSON).not_to receive(:parse)
63
63
  projects = VCR.use_cassette('all_projects_pagination') do
64
64
  test_client.projects limit: 1, page: 2
@@ -70,7 +70,7 @@ RSpec.describe Lokalise::JsonHandler do
70
70
  end
71
71
 
72
72
  it 'allows to customize #dump' do
73
- expect(Oj).to receive(:dump).and_return(dumped_json)
73
+ allow(Oj).to receive(:dump).and_return(dumped_json)
74
74
  expect(JSON).not_to receive(:dump)
75
75
  project = VCR.use_cassette('new_project') do
76
76
  test_client.create_project name: 'rspec proj', description: 'demo project for rspec'
@@ -7,6 +7,14 @@ RSpec.describe Lokalise::Error do
7
7
 
8
8
  after { Lokalise.reset_client! }
9
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
+
10
18
  it 'raises BadRequest when API token is invalid' do
11
19
  expect do
12
20
  VCR.use_cassette('error_invalid_token') do
@@ -40,6 +40,18 @@ RSpec.describe Lokalise::Client do
40
40
  expect(branch.created_by_email).to eq('bodrovis@protonmail.com')
41
41
  end
42
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
+
43
55
  specify '#create_branch' do
44
56
  branch = VCR.use_cassette('create_branch') do
45
57
  test_client.create_branch project_id, name: 'ruby-branch'
@@ -49,6 +49,18 @@ RSpec.describe Lokalise::Client do
49
49
  expect(comment.added_at_timestamp).to eq(1_544_380_904)
50
50
  end
51
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
+
52
64
  specify '#create_comments' do
53
65
  comments = VCR.use_cassette('create_comments') do
54
66
  test_client.create_comments project_id, key_id, [
@@ -48,6 +48,18 @@ RSpec.describe Lokalise::Client do
48
48
  expect(contributor.created_at_timestamp).to eq(1_534_865_725)
49
49
  end
50
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
+
51
63
  specify '#create_contributors' do
52
64
  contributor = VCR.use_cassette('create_contributors') do
53
65
  test_client.create_contributors project_id,
@@ -43,6 +43,18 @@ RSpec.describe Lokalise::Client do
43
43
  expect(status.color).to eq('#0079bf')
44
44
  end
45
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
+
46
58
  specify '#create_translation_status' do
47
59
  title = 'Reviewed by doctors'
48
60
  color = '#f2d600'
@@ -35,8 +35,8 @@ RSpec.describe Lokalise::Client do
35
35
  specify '#download_files' do
36
36
  response = VCR.use_cassette('download_files') do
37
37
  test_client.download_files project_id,
38
- "format": 'po',
39
- "original_filenames": true
38
+ format: 'po',
39
+ original_filenames: true
40
40
  end
41
41
 
42
42
  expect(response['project_id']).to eq(project_id)
@@ -44,15 +44,23 @@ RSpec.describe Lokalise::Client do
44
44
  end
45
45
 
46
46
  specify '#upload_file' do
47
- response = VCR.use_cassette('upload_file') do
47
+ process = VCR.use_cassette('upload_file') do
48
48
  test_client.upload_file project_id,
49
- "data": 'ZnI6DQogIHRlc3Q6IHRyYW5zbGF0aW9u',
50
- "filename": 'rspec.yml',
51
- 'lang_iso': 'ru'
49
+ data: 'ZnI6DQogIHRlc3Q6IHRyYW5zbGF0aW9u',
50
+ filename: 'rspec_async.yml',
51
+ lang_iso: 'ru'
52
52
  end
53
53
 
54
- expect(response['project_id']).to eq(project_id)
55
- expect(response['file']).to eq('rspec.yml')
56
- expect(response['result']['skipped']).to eq(1)
54
+ expect(process).to be_an_instance_of(Lokalise::Resources::QueuedProcess)
55
+ expect(process.process_id).to eq('85c42bf5eff44648ca2f01f9db67b7d306a2f282')
56
+ expect(process.status).to eq('queued')
57
+
58
+ reloaded_process = VCR.use_cassette('upload_file_queued_reload') do
59
+ process.reload_data
60
+ end
61
+
62
+ expect(reloaded_process.process_id).to eq(process.process_id)
63
+ expect(reloaded_process.status).to eq('finished')
64
+ expect(reloaded_process.details['files'][0]['status']).to eq('finished')
57
65
  end
58
66
  end
@@ -11,51 +11,69 @@ RSpec.describe Lokalise::Client do
11
11
  test_client.keys project_id
12
12
  end.collection
13
13
 
14
- expect(keys.count).to eq(1)
14
+ expect(keys.count).to eq(8)
15
15
  end
16
16
 
17
17
  it 'supports pagination' do
18
18
  keys = VCR.use_cassette('all_keys_pagination') do
19
- test_client.keys project_id, limit: 1, page: 1
19
+ test_client.keys project_id, limit: 2, page: 3
20
20
  end
21
21
 
22
- expect(keys.collection.count).to eq(1)
23
- expect(keys.total_results).to eq(1)
24
- expect(keys.total_pages).to eq(1)
25
- expect(keys.results_per_page).to eq(1)
26
- expect(keys.current_page).to eq(1)
22
+ expect(keys.collection.count).to eq(2)
23
+ expect(keys.total_results).to eq(8)
24
+ expect(keys.total_pages).to eq(4)
25
+ expect(keys.results_per_page).to eq(2)
26
+ expect(keys.current_page).to eq(3)
27
27
 
28
- expect(keys.next_page?).to eq(false)
29
- expect(keys.last_page?).to eq(true)
30
- expect(keys.prev_page?).to eq(false)
31
- expect(keys.first_page?).to eq(true)
28
+ expect(keys.next_page?).to eq(true)
29
+ expect(keys.last_page?).to eq(false)
30
+ expect(keys.prev_page?).to eq(true)
31
+ expect(keys.first_page?).to eq(false)
32
32
  end
33
33
  end
34
34
 
35
35
  specify '#key' do
36
36
  key = VCR.use_cassette('key') do
37
- test_client.key project_id, key_id, disable_references: 0
37
+ test_client.key project_id, 44_596_066, disable_references: 0
38
38
  end
39
39
 
40
- expect(key.key_id).to eq(key_id)
41
- expect(key.created_at).to eq('2018-12-03 19:11:30 (Etc/UTC)')
42
- expect(key.key_name['ios']).to eq('test')
43
- expect(key.filenames['web']).to eq('rspec.yml')
40
+ expect(key.key_id).to eq(44_596_066)
41
+ expect(key.project_id).to eq(project_id)
42
+ expect(key.branch).to eq('master')
43
+ expect(key.created_at).to eq('2020-05-11 11:20:33 (Etc/UTC)')
44
+ expect(key.created_at_timestamp).to eq(1_589_196_033)
45
+ expect(key.key_name['ios']).to eq('static_pages:index:welcome')
46
+ expect(key.filenames['web']).to eq('%LANG_ISO%.yml')
44
47
  expect(key.description).to eq('')
45
48
  expect(key.platforms).to eq(%w[web])
46
49
  expect(key.tags).to eq([])
47
- expect(key.comments.first['comment']).to eq('demo comment')
48
- expect(key.comments[1]['comment_id']).to eq(800_632)
50
+ expect(key.comments).to eq([])
49
51
  expect(key.screenshots).to eq([])
50
52
  expect(key.translations.first['modified_by_email']).to eq('bodrovis@protonmail.com')
51
53
  expect(key.is_plural).to eq(false)
52
54
  expect(key.plural_name).to eq('')
53
- expect(key.is_hidden).to eq(false)
55
+ expect(key.is_hidden).to eq(true)
54
56
  expect(key.is_archived).to eq(false)
55
57
  expect(key.context).to eq('')
58
+ expect(key.base_words).to eq(1)
56
59
  expect(key.char_limit).to eq(0)
57
60
  expect(key.custom_attributes).to eq('')
58
- expect(key.base_words).to eq(1)
61
+ expect(key.modified_at).to eq('2020-05-11 11:20:33 (Etc/UTC)')
62
+ expect(key.modified_at_timestamp).to eq(1_589_196_033)
63
+ expect(key.translations_modified_at).to eq('2020-05-15 10:44:42 (Etc/UTC)')
64
+ expect(key.translations_modified_at_timestamp).to eq(1_589_539_482)
65
+ end
66
+
67
+ specify '#reload_data' do
68
+ key = VCR.use_cassette('key') do
69
+ test_client.key project_id, 44_596_066, disable_references: 0
70
+ end
71
+
72
+ reloaded_key = VCR.use_cassette('key') do
73
+ key.reload_data disable_references: 0
74
+ end
75
+
76
+ expect(reloaded_key.key_id).to eq(key.key_id)
59
77
  end
60
78
 
61
79
  specify '#create_keys' do
@@ -63,6 +63,18 @@ RSpec.describe Lokalise::Client do
63
63
  expect(language.plural_forms).to eq(%w[one other])
64
64
  end
65
65
 
66
+ specify '#reload_data' do
67
+ language = VCR.use_cassette('language') do
68
+ test_client.language project_id, language_id
69
+ end
70
+
71
+ reloaded_language = VCR.use_cassette('language') do
72
+ language.reload_data
73
+ end
74
+
75
+ expect(reloaded_language.lang_id).to eq(language.lang_id)
76
+ end
77
+
66
78
  specify '#create_languages' do
67
79
  language = VCR.use_cassette('create_languages') do
68
80
  test_client.create_languages project_id, lang_iso: 'ab', custom_name: 'rspec lang'
@@ -54,6 +54,18 @@ RSpec.describe Lokalise::Client do
54
54
  expect(order.total).to eq(0.07)
55
55
  end
56
56
 
57
+ specify '#reload_data' do
58
+ order = VCR.use_cassette('order') do
59
+ test_client.order team_id, order_id
60
+ end
61
+
62
+ reloaded_order = VCR.use_cassette('order') do
63
+ order.reload_data
64
+ end
65
+
66
+ expect(reloaded_order.order_id).to eq(order.order_id)
67
+ end
68
+
57
69
  specify '#create_order' do
58
70
  order = VCR.use_cassette('create_order') do
59
71
  test_client.create_order team_id,
@@ -7,9 +7,10 @@ RSpec.describe Lokalise::Client do
7
7
  it 'returns all payment cards' do
8
8
  cards = VCR.use_cassette('all_payment_cards') do
9
9
  test_client.payment_cards
10
- end.collection
10
+ end
11
11
 
12
- card = cards.first
12
+ expect(cards.user_id).to eq(20_181)
13
+ card = cards.collection.first
13
14
  expect(card.card_id).to eq(1774)
14
15
  expect(card.last4).to eq('0358')
15
16
  end
@@ -35,9 +36,9 @@ RSpec.describe Lokalise::Client do
35
36
  specify '#create_payment_card' do
36
37
  card = VCR.use_cassette('new_payment_card') do
37
38
  test_client.create_payment_card number: '4242424242424242',
38
- "cvc": '123',
39
- "exp_month": 1,
40
- "exp_year": 2030
39
+ cvc: '123',
40
+ exp_month: 1,
41
+ exp_year: 2030
41
42
  end
42
43
 
43
44
  expect(card.card_id).to eq(card_id)
@@ -49,12 +50,25 @@ RSpec.describe Lokalise::Client do
49
50
  test_client.payment_card card_id
50
51
  end
51
52
 
53
+ expect(card.user_id).to eq(20_181)
52
54
  expect(card.card_id).to eq(card_id)
53
55
  expect(card.brand).to eq('Visa')
54
56
  expect(card.last4).to eq('4242')
55
57
  expect(card.created_at).to eq('2019-03-19 17:01:22 (Etc/UTC)')
56
58
  end
57
59
 
60
+ specify '#reload_data' do
61
+ card = VCR.use_cassette('payment_card') do
62
+ test_client.payment_card card_id
63
+ end
64
+
65
+ reloaded_card = VCR.use_cassette('payment_card') do
66
+ card.reload_data
67
+ end
68
+
69
+ expect(reloaded_card.card_id).to eq(card.card_id)
70
+ end
71
+
58
72
  specify '#destroy_payment_card' do
59
73
  result = VCR.use_cassette('destroy_payment_card') do
60
74
  test_client.destroy_payment_card card_id
@@ -51,6 +51,18 @@ RSpec.describe Lokalise::Client do
51
51
  expect(project.statistics['progress_total']).to eq(18)
52
52
  end
53
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
+
54
66
  specify '#create_project' do
55
67
  project = VCR.use_cassette('new_project') do
56
68
  test_client.create_project name: 'rspec proj', description: 'demo project for rspec'
@@ -0,0 +1,57 @@
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