diff --git a/.rubocop.yml b/.rubocop.yml index 9cbc530..0dd2ad0 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -3,7 +3,7 @@ require: - rubocop-rspec AllCops: - TargetRubyVersion: 2.6 + TargetRubyVersion: 2.5 NewCops: enable Layout/SpaceInsideHashLiteralBraces: @@ -83,3 +83,6 @@ RSpec/FilePath: RSpec/MessageSpies: EnforcedStyle: receive + +RSpec/MultipleMemoizedHelpers: + Max: 10 \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index f38b8c4..ef19617 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,8 @@ language: ruby rvm: - 2.5.8 - 2.6.6 -- 2.7.1 +- 2.7.2 +- 3.0.0 install: bundle install --retry=3 diff --git a/LICENSE b/LICENSE index 7dd334e..45b6b24 100644 --- a/LICENSE +++ b/LICENSE @@ -1,22 +1,13 @@ -MIT License +BSD 3 Clause -Copyright (c) 2018 Lokalise team, Ilya Bodrov, Roman Kutanov +Copyright 2021 Lokalise Group, Ilya Bodrov -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file +2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/README.md b/README.md index e5ac04b..475f5e0 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,6 @@ Detailed documentation can be found at [lokalise.github.io/ruby-lokalise-api](ht ## License -This gem is licensed under the [MIT License](https://github.com/lokalise/ruby-lokalise-api/blob/master/LICENSE). +This gem is licensed under the [BSD 3 Clause license](https://github.com/lokalise/ruby-lokalise-api/blob/master/LICENSE). Prior to version 4 the license type was MIT. Copyright (c) [Lokalise team](http://lokalise.co), [Ilya Bodrov](http://bodrovis.tech) diff --git a/docs/Gemfile b/docs/Gemfile index f3e8f65..838a076 100644 --- a/docs/Gemfile +++ b/docs/Gemfile @@ -1,4 +1,6 @@ -source "https://rubygems.org" +# frozen_string_literal: true + +source 'https://rubygems.org' # Hello! This is where you manage which Jekyll version is used to run. # When you want to use a different version, change it below, save the @@ -8,30 +10,30 @@ source "https://rubygems.org" # # This will help ensure the proper Jekyll version is running. # Happy Jekylling! -#gem "jekyll", "~> 3.9.0" +gem "jekyll", "~> 3.9.0" # This is the default theme for new Jekyll sites. You may change this to anything you like. -gem "minima", "~> 2.0" +gem 'minima', '~> 2.0' # If you want to use GitHub Pages, remove the "gem "jekyll"" above and # uncomment the line below. To upgrade, run `bundle update github-pages`. -gem "github-pages", "~> 207", group: :jekyll_plugins +gem 'github-pages', '~> 211', group: :jekyll_plugins # If you have any plugins, put them here! group :jekyll_plugins do - gem "jekyll-feed", "~> 0.6" + gem 'jekyll-feed', '~> 0.15' end # Windows does not include zoneinfo files, so bundle the tzinfo-data gem # and associated library. -install_if -> { RUBY_PLATFORM =~ %r!mingw|mswin|java! } do - gem "tzinfo", "~> 1.2" - gem "tzinfo-data" +install_if -> { RUBY_PLATFORM =~ /mingw|mswin|java/ } do + gem 'tzinfo', '~> 1.2' + gem 'tzinfo-data' end # Performance-booster for watching directories on Windows -gem "wdm", "~> 0.1.0", :install_if => Gem.win_platform? +gem 'wdm', '~> 0.1.0', install_if: Gem.win_platform? # kramdown v2 ships without the gfm parser by default. If you're using # kramdown v1, comment out this line. -gem "kramdown-parser-gfm" +gem 'kramdown-parser-gfm' diff --git a/docs/additional_info/changelog.md b/docs/additional_info/changelog.md index 27fab94..bfc5843 100644 --- a/docs/additional_info/changelog.md +++ b/docs/additional_info/changelog.md @@ -1,5 +1,12 @@ # Changelog +## 4.0.0 (02-Feb-20) + +* **License type is now BSD 3 Clause** +* Added `auto_close_items` attribute for the `Task` endpoint +* Dependency updates +* Test against Ruby 3 + ## 3.1.0 (08-Jul-20) * Added all recently introduced attributes for the following endpoints: `Contributor` and `Key` diff --git a/docs/additional_info/license_type.md b/docs/additional_info/license_type.md index 2bc8632..45b6b24 100644 --- a/docs/additional_info/license_type.md +++ b/docs/additional_info/license_type.md @@ -1,22 +1,13 @@ -MIT License +BSD 3 Clause -Copyright (c) 2018 Lokalise team, Ilya Bodrov, Roman Kutanov +Copyright 2021 Lokalise Group, Ilya Bodrov -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/lib/ruby-lokalise-api/collections/base.rb b/lib/ruby-lokalise-api/collections/base.rb index df5469c..8888a48 100644 --- a/lib/ruby-lokalise-api/collections/base.rb +++ b/lib/ruby-lokalise-api/collections/base.rb @@ -91,7 +91,7 @@ def fetch_page(page_num) # Collection example: `{ "content": {"comments": [ ... ]} }` def produce_collection_for(response) model_class = self.class.name.base_class_name - data_key_plural = data_key_for model_class, true, true + data_key_plural = data_key_for model_class: model_class, plural: true, collection: true # Fetch collection data and instantiate an individual resource for each object # We also preserve the `client` to be able to chain API methods later diff --git a/lib/ruby-lokalise-api/data/attributes.json b/lib/ruby-lokalise-api/data/attributes.json index f9cde5a..38d3ec7 100644 --- a/lib/ruby-lokalise-api/data/attributes.json +++ b/lib/ruby-lokalise-api/data/attributes.json @@ -162,6 +162,7 @@ "languages", "auto_close_languages", "auto_close_task", + "auto_close_items", "completed_at", "completed_at_timestamp", "completed_by", diff --git a/lib/ruby-lokalise-api/resources/base.rb b/lib/ruby-lokalise-api/resources/base.rb index 346a6d0..f078d61 100644 --- a/lib/ruby-lokalise-api/resources/base.rb +++ b/lib/ruby-lokalise-api/resources/base.rb @@ -95,7 +95,7 @@ def prepare_params(params) # Instantiates a new resource or collection based on the given response def object_from(response, params) model_class = name.base_class_name - data_key_plural = data_key_for model_class, true + data_key_plural = data_key_for model_class: model_class, plural: true # Preserve the initial path to allow chaining response['path'] = params.delete(:_initial_path) if params.key?(:_initial_path) @@ -107,7 +107,7 @@ def object_from(response, params) end def produce_resource(model_class, response) - data_key_singular = data_key_for model_class + data_key_singular = data_key_for model_class: model_class if response['content'].key? data_key_singular data = response['content'].delete data_key_singular response['content'].merge! data @@ -124,7 +124,7 @@ def produce_collection(model_class, response, params) # Generates path for the individual resource based on the path for the collection def infer_path_from(response, endpoint_generator = nil) id_key = id_key_for self.class.name.base_class_name - data_key = data_key_for self.class.name.base_class_name + data_key = data_key_for model_class: self.class.name.base_class_name path_with_id response, id_key, data_key, endpoint_generator end @@ -164,7 +164,7 @@ def id_from(response, id_key, data_key) # Store all resources attributes under the corresponding instance variables. # `ATTRIBUTES` is defined inside resource-specific classes def populate_attributes_for(content) - data_key = data_key_for self.class.name.base_class_name + data_key = data_key_for model_class: self.class.name.base_class_name self.class.const_get(:ATTRIBUTES).each do |attr| value = if content.key?(data_key) && content[data_key].is_a?(Hash) diff --git a/lib/ruby-lokalise-api/resources/project.rb b/lib/ruby-lokalise-api/resources/project.rb index ee21e1e..c95b228 100644 --- a/lib/ruby-lokalise-api/resources/project.rb +++ b/lib/ruby-lokalise-api/resources/project.rb @@ -6,7 +6,7 @@ class Project < Base supports :update, :destroy, [:reload_data, '', :find] def empty - self.class.empty @client, @path + '/empty' + self.class.empty @client, "#{@path}/empty" end class << self diff --git a/lib/ruby-lokalise-api/resources/webhook.rb b/lib/ruby-lokalise-api/resources/webhook.rb index f61ef89..e50e5be 100644 --- a/lib/ruby-lokalise-api/resources/webhook.rb +++ b/lib/ruby-lokalise-api/resources/webhook.rb @@ -6,7 +6,7 @@ class Webhook < Base supports :update, :destroy, [:reload_data, '', :find] def regenerate_secret - self.class.regenerate_secret @client, @path + '/secret/regenerate' + self.class.regenerate_secret @client, "#{@path}/secret/regenerate" end class << self diff --git a/lib/ruby-lokalise-api/utils/attribute_helpers.rb b/lib/ruby-lokalise-api/utils/attribute_helpers.rb index 463aeca..eddf906 100644 --- a/lib/ruby-lokalise-api/utils/attribute_helpers.rb +++ b/lib/ruby-lokalise-api/utils/attribute_helpers.rb @@ -16,16 +16,21 @@ module AttributeHelpers # @return [String] # @param model_class [String] # @param plural [Boolean] Should the returned value be pluralized? - def data_key_for(model_class, plural = false, collection = false) - data_key_plural = get_key('DATA_KEY_PLURAL', model_class, true, true) + def data_key_for(model_class:, plural: false, collection: false) + data_key_plural = get_key( + name: 'DATA_KEY_PLURAL', + model_class: model_class, + collection: true, + strict: true + ) return data_key_plural if collection && data_key_plural - data_key = get_key 'DATA_KEY', model_class, collection + data_key = get_key name: 'DATA_KEY', model_class: model_class, collection: collection return data_key unless plural - data_key + 's' + "#{data_key}s" end # Returns key used to determine resource id (for example `user_id` or `project_id`). @@ -35,7 +40,7 @@ def data_key_for(model_class, plural = false, collection = false) # @return [String] # @param model_class [String] def id_key_for(model_class) - get_key('ID_KEY', model_class) + '_id' + "#{get_key(name: 'ID_KEY', model_class: model_class)}_id" end # Loads attributes for the given resource based on its name @@ -52,7 +57,7 @@ def attributes_for(klass) private - def get_key(name, model_class, collection = false, strict = false) + def get_key(name:, model_class:, collection: false, strict: false) key = if collection && Module.const_defined?("Lokalise::Collections::#{model_class}::#{name}") Module.const_get "Lokalise::Collections::#{model_class}::#{name}" elsif Module.const_defined? "Lokalise::Resources::#{model_class}::#{name}" diff --git a/lib/ruby-lokalise-api/version.rb b/lib/ruby-lokalise-api/version.rb index bbeb468..7e1e3e0 100644 --- a/lib/ruby-lokalise-api/version.rb +++ b/lib/ruby-lokalise-api/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Lokalise - VERSION = '3.1.0' + VERSION = '4.0.0' end diff --git a/ruby-lokalise-api.gemspec b/ruby-lokalise-api.gemspec index 21dfe95..4cd12c8 100644 --- a/ruby-lokalise-api.gemspec +++ b/ruby-lokalise-api.gemspec @@ -10,8 +10,9 @@ Gem::Specification.new do |spec| spec.summary = 'Ruby interface to the Lokalise API' spec.description = 'Opinionated Ruby client for the Lokalise platform API allowing to work with translations, projects, users and other resources as with Ruby objects.' spec.homepage = 'https://github.com/lokalise/ruby-lokalise-api' - spec.license = 'MIT' + spec.license = 'BSD-3-Clause' spec.platform = Gem::Platform::RUBY + spec.required_ruby_version = '>= 2.5.0' spec.files = Dir['README.md', 'LICENSE', 'CHANGELOG.md', 'lib/**/*.rb', 'lib/ruby-lokalise-api/data/attributes.json', diff --git a/spec/fixtures/vcr_cassettes/task.yml b/spec/fixtures/vcr_cassettes/task.yml index 41ba1bc..71791b4 100644 --- a/spec/fixtures/vcr_cassettes/task.yml +++ b/spec/fixtures/vcr_cassettes/task.yml @@ -10,7 +10,7 @@ http_interactions: Accept: - application/json User-Agent: - - ruby-lokalise-api gem/2.2.0 + - ruby-lokalise-api gem/4.0.0 X-api-token: - "" response: @@ -20,46 +20,51 @@ http_interactions: headers: server: - nginx - date: - - Mon, 15 Jul 2019 16:48:52 GMT content-type: - application/json transfer-encoding: - chunked connection: - - close + - keep-alive vary: - Accept-Encoding - set-cookie: - - PHPSESSID=9fa044cab0b0ea1e4a974d5efcdc8081; expires=Fri, 13-Sep-2019 16:48:52 - GMT; Max-Age=5184000; path=/; secure; HttpOnly - expires: - - Thu, 19 Nov 1981 08:52:00 GMT cache-control: - - no-store, no-cache, must-revalidate, no-store, no-cache + - max-age=0, must-revalidate, no-cache, no-store, private + date: + - Tue, 02 Feb 2021 11:50:49 GMT pragma: - - no-cache, no-cache + - no-cache + x-content-type-options: + - nosniff + x-frame-options: + - deny + x-xss-protection: + - 1; mode=block + strict-transport-security: + - max-age=31536000 + referrer-policy: + - origin + expires: + - Tue, 02 Feb 2021 11:50:49 GMT access-control-allow-origin: - "*" access-control-allow-headers: - Content-Type body: encoding: ASCII-8BIT - string: '{"project_id":"803826145ba90b42d5d860.46800099","task":{"task_id":11925,"title":"node - updated","can_be_parent":true,"task_type":"review","parent_task_id":null,"closing_tags":[],"description":"","status":"in - progress","progress":1,"due_date":null,"due_date_timestamp":null,"keys_count":16,"words_count":275,"created_at":"2019-05-13 - 16:15:26 (Etc\/UTC)","created_at_timestamp":1557764126,"created_by":20181,"created_by_email":"bodrovis@protonmail.com","languages":[{"language_iso":"sq","users":[{"user_id":20181,"email":"bodrovis@protonmail.com","fullname":"Ilya - B"}],"groups":[],"keys":[15519786,15571975,15571976,15814906,20822936,20945747,20988544,20988547,20988554,20988567,20988568,20988569,20988570,20988571,20988596,21717815],"status":"created","progress":0,"initial_tm_leverage":[],"keys_count":16,"words_count":37,"completed_at":null,"completed_at_timestamp":null,"completed_by":null,"completed_by_email":null},{"language_iso":"ar_001","users":[{"user_id":20181,"email":"bodrovis@protonmail.com","fullname":"Ilya - B"},{"user_id":33599,"email":"twilight_church@list.ru","fullname":"Joe"}],"groups":[],"keys":[15519786,15571975,15571976,15814906,20822936,20945747,20988544,20988547,20988567,20988568,20988569,20988570,20988571,20988596,21717815],"status":"created","progress":0,"initial_tm_leverage":[],"keys_count":15,"words_count":36,"completed_at":null,"completed_at_timestamp":null,"completed_by":null,"completed_by_email":null},{"language_iso":"bm","users":[{"user_id":20181,"email":"bodrovis@protonmail.com","fullname":"Ilya - B"},{"user_id":33599,"email":"twilight_church@list.ru","fullname":"Joe"}],"groups":[],"keys":[20822936,20945747,20988544,20988547,20988554,20988567,20988568,20988569,20988570,20988571,20988596,21717815],"status":"created","progress":0,"initial_tm_leverage":[],"keys_count":12,"words_count":17,"completed_at":null,"completed_at_timestamp":null,"completed_by":null,"completed_by_email":null},{"language_iso":"ca","users":[{"user_id":20181,"email":"bodrovis@protonmail.com","fullname":"Ilya - B"},{"user_id":33599,"email":"twilight_church@list.ru","fullname":"Joe"}],"groups":[],"keys":[20822936,20945747,20988544,20988547,20988567,20988568,20988569,20988570,20988571,20988596,21717815],"status":"created","progress":0,"initial_tm_leverage":[],"keys_count":11,"words_count":16,"completed_at":null,"completed_at_timestamp":null,"completed_by":null,"completed_by_email":null},{"language_iso":"zh_TW","users":[{"user_id":20181,"email":"bodrovis@protonmail.com","fullname":"Ilya - B"}],"groups":[],"keys":[15519786,15814906,20822936,20945747,20988544,20988547,20988554,20988567,20988568,20988569,20988570,20988571,20988596,21717815],"status":"created","progress":0,"initial_tm_leverage":[],"keys_count":14,"words_count":29,"completed_at":null,"completed_at_timestamp":null,"completed_by":null,"completed_by_email":null},{"language_iso":null,"users":[{"user_id":20181,"email":"bodrovis@protonmail.com","fullname":"Ilya - B"},{"user_id":33599,"email":"twilight_church@list.ru","fullname":"Joe"}],"groups":[],"keys":[0],"status":"created","progress":0,"initial_tm_leverage":[],"keys_count":16,"words_count":37,"completed_at":null,"completed_at_timestamp":null,"completed_by":null,"completed_by_email":null},{"language_iso":"en-us","users":[{"user_id":20181,"email":"bodrovis@protonmail.com","fullname":"Ilya - B"}],"groups":[],"keys":[15519786,15571975,15571976,15814906,20822936,20945747,20988544,20988547,20988554,20988567,20988568,20988569,20988570,20988571,20988596,21717815],"status":"created","progress":0,"initial_tm_leverage":[],"keys_count":16,"words_count":37,"completed_at":null,"completed_at_timestamp":null,"completed_by":null,"completed_by_email":null},{"language_iso":"ru","users":[{"user_id":33599,"email":"twilight_church@list.ru","fullname":"Joe"},{"user_id":20181,"email":"bodrovis@protonmail.com","fullname":"Ilya - B"}],"groups":[],"keys":[15571975,15571976,20822936,20988567,20988568,20988570,20988571,20988596,21717815],"status":"in - progress","progress":11,"initial_tm_leverage":[],"keys_count":9,"words_count":11,"completed_at":null,"completed_at_timestamp":null,"completed_by":null,"completed_by_email":null},{"language_iso":"es","users":[{"user_id":20181,"email":"bodrovis@protonmail.com","fullname":"Ilya - B"},{"user_id":33599,"email":"twilight_church@list.ru","fullname":"Joe"}],"groups":[],"keys":[15519786,15814906,20822936,20945747,20988544,20988547,20988567,20988568,20988569,20988570,20988571,20988596,21717815],"status":"created","progress":0,"initial_tm_leverage":[],"keys_count":13,"words_count":28,"completed_at":null,"completed_at_timestamp":null,"completed_by":null,"completed_by_email":null},{"language_iso":"f_over","users":[{"user_id":33599,"email":"twilight_church@list.ru","fullname":"Joe"},{"user_id":20181,"email":"bodrovis@protonmail.com","fullname":"Ilya - B"}],"groups":[],"keys":[15519786,15571975,15571976,20822936,20945747,20988544,20988547,20988567,20988568,20988569,20988570,20988571,20988596,21717815],"status":"created","progress":0,"initial_tm_leverage":[],"keys_count":14,"words_count":27,"completed_at":null,"completed_at_timestamp":null,"completed_by":null,"completed_by_email":null}],"auto_close_languages":true,"auto_close_task":true,"completed_at":null,"completed_at_timestamp":null,"completed_by":null,"completed_by_email":null,"do_lock_translations":false,"custom_translation_status_ids":[]}}' - http_version: - recorded_at: Mon, 15 Jul 2019 16:48:32 GMT -recorded_with: VCR 5.0.0 + string: '{"project_id":"803826145ba90b42d5d860.46800099","branch":"master","task":{"task_id":11925,"title":"node + updated","can_be_parent":false,"task_type":"review","parent_task_id":null,"closing_tags":[],"description":"","status":"completed","progress":0,"due_date":null,"due_date_timestamp":null,"keys_count":16,"words_count":275,"created_at":"2019-05-13 + 16:15:26 (Etc\/UTC)","created_at_timestamp":1557764126,"created_by":20181,"created_by_email":"bodrovis@protonmail.com","source_language_iso":"en","languages":[{"language_iso":"sq","users":[{"user_id":20181,"email":"bodrovis@protonmail.com","fullname":"Ilya + B"}],"groups":[],"keys":[],"status":"created","progress":0,"initial_tm_leverage":{"0%+":0,"60%+":0,"75%+":0,"95%+":0,"100%":0},"keys_count":16,"words_count":37,"completed_at":null,"completed_at_timestamp":null,"completed_by":null,"completed_by_email":null},{"language_iso":"ar_001","users":[{"user_id":20181,"email":"bodrovis@protonmail.com","fullname":"Ilya + B"},{"user_id":33599,"email":"twilight_church@list.ru","fullname":"Joe"}],"groups":[],"keys":[],"status":"created","progress":0,"initial_tm_leverage":{"0%+":0,"60%+":0,"75%+":0,"95%+":0,"100%":0},"keys_count":15,"words_count":36,"completed_at":null,"completed_at_timestamp":null,"completed_by":null,"completed_by_email":null},{"language_iso":"bm","users":[{"user_id":20181,"email":"bodrovis@protonmail.com","fullname":"Ilya + B"},{"user_id":33599,"email":"twilight_church@list.ru","fullname":"Joe"}],"groups":[],"keys":[],"status":"created","progress":0,"initial_tm_leverage":{"0%+":0,"60%+":0,"75%+":0,"95%+":0,"100%":0},"keys_count":12,"words_count":17,"completed_at":null,"completed_at_timestamp":null,"completed_by":null,"completed_by_email":null},{"language_iso":"ca","users":[{"user_id":20181,"email":"bodrovis@protonmail.com","fullname":"Ilya + B"},{"user_id":33599,"email":"twilight_church@list.ru","fullname":"Joe"}],"groups":[],"keys":[],"status":"created","progress":0,"initial_tm_leverage":{"0%+":0,"60%+":0,"75%+":0,"95%+":0,"100%":0},"keys_count":11,"words_count":16,"completed_at":null,"completed_at_timestamp":null,"completed_by":null,"completed_by_email":null},{"language_iso":null,"users":[{"user_id":20181,"email":"bodrovis@protonmail.com","fullname":"Ilya + B"}],"groups":[],"keys":[],"status":"created","progress":0,"initial_tm_leverage":{"0%+":0,"60%+":0,"75%+":0,"95%+":0,"100%":0},"keys_count":14,"words_count":29,"completed_at":null,"completed_at_timestamp":null,"completed_by":null,"completed_by_email":null},{"language_iso":null,"users":[{"user_id":20181,"email":"bodrovis@protonmail.com","fullname":"Ilya + B"},{"user_id":33599,"email":"twilight_church@list.ru","fullname":"Joe"}],"groups":[],"keys":[],"status":"created","progress":0,"initial_tm_leverage":{"0%+":0,"60%+":0,"75%+":0,"95%+":0,"100%":0},"keys_count":16,"words_count":37,"completed_at":null,"completed_at_timestamp":null,"completed_by":null,"completed_by_email":null},{"language_iso":"en-us","users":[{"user_id":20181,"email":"bodrovis@protonmail.com","fullname":"Ilya + B"}],"groups":[],"keys":[],"status":"created","progress":0,"initial_tm_leverage":{"0%+":0,"60%+":0,"75%+":0,"95%+":0,"100%":0},"keys_count":16,"words_count":37,"completed_at":null,"completed_at_timestamp":null,"completed_by":null,"completed_by_email":null},{"language_iso":"ru","users":[{"user_id":33599,"email":"twilight_church@list.ru","fullname":"Joe"},{"user_id":20181,"email":"bodrovis@protonmail.com","fullname":"Ilya + B"}],"groups":[],"keys":[],"status":"created","progress":0,"initial_tm_leverage":{"0%+":0,"60%+":0,"75%+":0,"95%+":0,"100%":0},"keys_count":9,"words_count":11,"completed_at":null,"completed_at_timestamp":null,"completed_by":null,"completed_by_email":null},{"language_iso":"es","users":[{"user_id":20181,"email":"bodrovis@protonmail.com","fullname":"Ilya + B"},{"user_id":33599,"email":"twilight_church@list.ru","fullname":"Joe"}],"groups":[],"keys":[],"status":"created","progress":0,"initial_tm_leverage":{"0%+":0,"60%+":0,"75%+":0,"95%+":0,"100%":0},"keys_count":13,"words_count":28,"completed_at":null,"completed_at_timestamp":null,"completed_by":null,"completed_by_email":null},{"language_iso":"f_over","users":[{"user_id":33599,"email":"twilight_church@list.ru","fullname":"Joe"},{"user_id":20181,"email":"bodrovis@protonmail.com","fullname":"Ilya + B"}],"groups":[],"keys":[],"status":"created","progress":0,"initial_tm_leverage":{"0%+":0,"60%+":0,"75%+":0,"95%+":0,"100%":0},"keys_count":14,"words_count":27,"completed_at":null,"completed_at_timestamp":null,"completed_by":null,"completed_by_email":null}],"auto_close_items":true,"auto_close_languages":true,"auto_close_task":true,"completed_at":"2019-10-01 + 11:09:12 (Etc\/UTC)","completed_at_timestamp":1569928152,"completed_by":20181,"completed_by_email":"bodrovis@protonmail.com","do_lock_translations":false,"custom_translation_status_ids":[]}}' + recorded_at: Tue, 02 Feb 2021 11:50:50 GMT +recorded_with: VCR 6.0.0 diff --git a/spec/lib/ruby-lokalise-api/custom_json_parser_spec.rb b/spec/lib/ruby-lokalise-api/custom_json_parser_spec.rb index b16c344..5af4e0d 100644 --- a/spec/lib/ruby-lokalise-api/custom_json_parser_spec.rb +++ b/spec/lib/ruby-lokalise-api/custom_json_parser_spec.rb @@ -27,7 +27,7 @@ '{":name":"rspec proj",":description":"demo project for rspec"}' end - # rubocop:disable RSpec/LeakyConstantDeclaration + # rubocop:disable RSpec/LeakyConstantDeclaration, Lint/ConstantDefinitionInBlock before do module Lokalise module JsonHandler @@ -55,10 +55,10 @@ def custom_load(obj) end end end - # rubocop:enable RSpec/LeakyConstantDeclaration + # rubocop:enable RSpec/LeakyConstantDeclaration, Lint/ConstantDefinitionInBlock it 'allows to customize #load' do - expect(Oj).to receive(:load).and_return(loaded_json) + allow(Oj).to receive(:load).and_return(loaded_json) expect(JSON).not_to receive(:parse) projects = VCR.use_cassette('all_projects_pagination') do test_client.projects limit: 1, page: 2 @@ -70,7 +70,7 @@ def custom_load(obj) end it 'allows to customize #dump' do - expect(Oj).to receive(:dump).and_return(dumped_json) + allow(Oj).to receive(:dump).and_return(dumped_json) expect(JSON).not_to receive(:dump) project = VCR.use_cassette('new_project') do test_client.create_project name: 'rspec proj', description: 'demo project for rspec' diff --git a/spec/lib/ruby-lokalise-api/rest/payment_cards_spec.rb b/spec/lib/ruby-lokalise-api/rest/payment_cards_spec.rb index d993927..6929ef5 100644 --- a/spec/lib/ruby-lokalise-api/rest/payment_cards_spec.rb +++ b/spec/lib/ruby-lokalise-api/rest/payment_cards_spec.rb @@ -36,9 +36,9 @@ specify '#create_payment_card' do card = VCR.use_cassette('new_payment_card') do test_client.create_payment_card number: '4242424242424242', - "cvc": '123', - "exp_month": 1, - "exp_year": 2030 + cvc: '123', + exp_month: 1, + exp_year: 2030 end expect(card.card_id).to eq(card_id) diff --git a/spec/lib/ruby-lokalise-api/rest/tasks_spec.rb b/spec/lib/ruby-lokalise-api/rest/tasks_spec.rb index 15ac9f7..0588bce 100644 --- a/spec/lib/ruby-lokalise-api/rest/tasks_spec.rb +++ b/spec/lib/ruby-lokalise-api/rest/tasks_spec.rb @@ -35,8 +35,8 @@ expect(task.task_id).to eq(11_925) expect(task.title).to eq('node updated') expect(task.description).to eq('') - expect(task.status).to eq('in progress') - expect(task.progress).to eq(1) + expect(task.status).to eq('completed') + expect(task.progress).to eq(0) expect(task.due_date).to eq(nil) expect(task.due_date_timestamp).to eq(nil) expect(task.keys_count).to eq(16) @@ -45,17 +45,18 @@ expect(task.created_at_timestamp).to eq(1_557_764_126) expect(task.created_by).to eq(20_181) expect(task.created_by_email).to eq('bodrovis@protonmail.com') - expect(task.can_be_parent).to eq(true) + expect(task.can_be_parent).to eq(false) expect(task.task_type).to eq('review') expect(task.parent_task_id).to eq(nil) expect(task.closing_tags).to eq([]) expect(task.languages.first['language_iso']).to eq('sq') expect(task.auto_close_languages).to eq(true) expect(task.auto_close_task).to eq(true) - expect(task.completed_by).to eq(nil) - expect(task.completed_by_email).to eq(nil) - expect(task.completed_at).to eq(nil) - expect(task.completed_at_timestamp).to eq(nil) + expect(task.auto_close_items).to eq(true) + expect(task.completed_by).to eq(20_181) + expect(task.completed_by_email).to eq('bodrovis@protonmail.com') + expect(task.completed_at).to eq('2019-10-01 11:09:12 (Etc/UTC)') + expect(task.completed_at_timestamp).to eq(1_569_928_152) expect(task.do_lock_translations).to eq(false) expect(task.custom_translation_status_ids).to eq([]) end