releaf-i18n_database 1.1.22 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 200472e83299da49355b167f2c466cc71d2621ecaa09e8e3db5764628f6dc07a
4
- data.tar.gz: 35a0a136fc008f466121af6c8c258bee98aed6b3b3c44281243ec20aba29290d
3
+ metadata.gz: 26da56d1b3cb25df3efd5f142096f56eb3a0254b53c406a87d9093964524fa61
4
+ data.tar.gz: 86e216014dce28f62e0c48cf9bbcb70a82f2bd5bb71291678b2f745ae2fec9ef
5
5
  SHA512:
6
- metadata.gz: '05360029bb812dad3b9ea3b9cbe4fa450f6da88aa681433d8af3bf00bc9d31da5f475e76beab0298447f28bd6de67bd4c873c068ee751d1addb0564cad817605'
7
- data.tar.gz: 8964ebc81394db0bc72dedb816dd11220905e5ee4da0540d3f5ac90e51d687eaae494224e0b83df03e54cc9f9173b28f49ec4b1fc7e134723b0219c18548bcb6
6
+ metadata.gz: 748958207fd580b1cc080ef73eb313114a4f0a9bdf1aa0a4e5e97191bac7f030998e2fb6f8fcefbf802e1a114102169e5d3ccec4965152f7cb12815781fb004e
7
+ data.tar.gz: f926dc8be53963f55a08346e7a0526cdd85689a6c1f5a5a9f7fee61ccb83084c576b6c9d957c37fc10b35db7b1ee9f01d885dbc63944c779ecddd3eabc0d07bc
@@ -0,0 +1,2 @@
1
+ //= link controllers/releaf/i18n_database/translations.css
2
+ //= link controllers/releaf/i18n_database/translations.js
@@ -152,7 +152,7 @@ class Releaf::I18nDatabase::TranslationsController < ::Releaf::ActionController
152
152
  end
153
153
 
154
154
  def export_file_name
155
- "#{Rails.application.class.parent_name.underscore}_translations_#{Time.now.strftime('%Y_%m_%d_%H_%M_%S')}.xlsx"
155
+ "#{Rails.application.class.module_parent_name.underscore}_translations_#{Time.now.strftime('%Y_%m_%d_%H_%M_%S')}.xlsx"
156
156
  end
157
157
 
158
158
  def import_file_path
@@ -34,8 +34,8 @@ module Releaf::I18nDatabase
34
34
  end
35
35
 
36
36
  def file_format_error?(error_class_name, error_message)
37
- return true if ['Zip::ZipError','Ole::Storage::FormatError' ].include?(error_class_name)
38
- error_class_name == 'ArgumentError' && error_message.match("Don't know how to open file").present?
37
+ return true if ['Zip::Error','Ole::Storage::FormatError' ].include?(error_class_name)
38
+ error_class_name == 'ArgumentError' && error_message.match("Can't detect the type").present?
39
39
  end
40
40
 
41
41
  def translations
@@ -68,7 +68,7 @@ class Releaf::I18nDatabase::TranslationsStore
68
68
  Releaf::I18nDatabase::I18nEntryTranslation
69
69
  .joins(:i18n_entry)
70
70
  .where.not(text: '')
71
- .pluck("CONCAT(locale, '.', releaf_i18n_entries.key) AS translation_key", "text")
71
+ .pluck(Arel.sql("CONCAT(locale, '.', releaf_i18n_entries.key) AS translation_key"), "text")
72
72
  .to_h
73
73
  end
74
74
 
@@ -13,7 +13,7 @@ module Releaf::I18nDatabase
13
13
  blank_where_collection = blank_where_collection.where(column.eq('').or(column.eq(nil)))
14
14
  end
15
15
 
16
- collection.where(blank_where_collection.where_values.reduce(:or))
16
+ collection.where(blank_where_collection.where_clause.send(:predicates).reduce(:or))
17
17
  end
18
18
 
19
19
  def self.filter_by_text(collection, lookup_string)
@@ -3,7 +3,7 @@ module Releaf::I18nDatabase
3
3
  self.table_name = "releaf_i18n_entries"
4
4
 
5
5
  validates_presence_of :key
6
- validates_uniqueness_of :key
6
+ validates_uniqueness_of :key, case_sensitive: true
7
7
  validates_length_of :key, maximum: 255
8
8
 
9
9
  has_many :i18n_entry_translation, dependent: :destroy,
@@ -14,7 +14,7 @@
14
14
  %input{type: "text", class: "text", name: "translations[][localizations][#{locale}]"}
15
15
  %td.delete-column.only-icon
16
16
  = releaf_button(nil, "times", class: %w(danger remove-nested-item), title: t("Remove", scope: controller_scope_name))
17
- %section.nested{data: {name: "translations", releaf: {template: html_escape(template_html)}}}
17
+ %section.nested{data: {name: "translations", releaf: {template: template_html.to_str}}}
18
18
  %table.table
19
19
  %thead
20
20
  %tr
@@ -1,4 +1,4 @@
1
- require 'axlsx_rails'
1
+ require 'caxlsx_rails'
2
2
  require 'i18n'
3
3
  require 'rails-i18n'
4
4
  require 'roo'
@@ -1,7 +1,7 @@
1
1
  module Releaf::I18nDatabase
2
2
  class Engine < ::Rails::Engine
3
- initializer 'precompile', group: :all do |app|
4
- app.config.assets.precompile += %w(controllers/releaf/i18n_database/*)
3
+ initializer 'releaf_i18n_database.assets_precompile', group: :all do |app|
4
+ app.config.assets.precompile << "releaf_i18n_database_manifest.js"
5
5
  end
6
6
  end
7
7
  end
@@ -5,7 +5,7 @@ describe Releaf::I18nDatabase::Translations::BuildersCommon, type: :class do
5
5
  include Releaf::I18nDatabase::Translations::BuildersCommon
6
6
  end
7
7
  class TableBuilderTestHelper < ActionView::Base; end
8
- let(:template){ TableBuilderTestHelper.new }
8
+ let(:template){ TableBuilderTestHelper.new(ActionView::LookupContext.new(nil), {}, nil) }
9
9
  let(:subject){ I18nBuildersCommonInheriter.new(template) }
10
10
 
11
11
  describe "#action_url" do
@@ -4,7 +4,7 @@ describe Releaf::I18nDatabase::Translations::EditBuilder, type: :class do
4
4
  class TableBuilderTestHelper < ActionView::Base
5
5
  def protect_against_forgery?; end
6
6
  end
7
- let(:template){ TableBuilderTestHelper.new }
7
+ let(:template){ TableBuilderTestHelper.new(ActionView::LookupContext.new(nil), {}, nil) }
8
8
  let(:resource_class){ Releaf::I18nDatabase::Translation }
9
9
  let(:subject){ described_class.new(template) }
10
10
 
@@ -12,7 +12,7 @@ describe Releaf::I18nDatabase::Translations::EditBuilder, type: :class do
12
12
  it "returns section blocks wrapped within edit form" do
13
13
  allow(subject).to receive(:action_url).with(:update).and_return("update_url")
14
14
  allow(subject).to receive(:section_blocks).and_return(["a", "b"])
15
- result = '<section><form action="update_url" accept-charset="UTF-8" method="post"><input name="utf8" type="hidden" value="&#x2713;" />ab</form></section>'
15
+ result = '<section><form action="update_url" accept-charset="UTF-8" method="post">ab</form></section>'
16
16
  expect(subject.section).to eq(result)
17
17
  end
18
18
  end
@@ -15,7 +15,7 @@ describe Releaf::I18nDatabase::Translations::IndexBuilder, type: :class do
15
15
  end
16
16
  end
17
17
  end
18
- let(:template){ IndexBuilderTestHelper.new }
18
+ let(:template){ IndexBuilderTestHelper.new(ActionView::LookupContext.new(nil), {}, nil) }
19
19
  let(:resource_class){ Releaf::I18nDatabase::Translation }
20
20
  let(:subject){ described_class.new(template) }
21
21
 
@@ -74,7 +74,7 @@ describe Releaf::I18nDatabase::Translations::IndexBuilder, type: :class do
74
74
  describe "#import_form" do
75
75
  it "returns import form" do
76
76
  allow(subject).to receive(:url_for).with(action: 'import').and_return("import_url")
77
- result = "<form class=\"import\" enctype=\"multipart/form-data\" action=\"import_url\" accept-charset=\"UTF-8\" method=\"post\"><input name=\"utf8\" type=\"hidden\" value=\"&#x2713;\" /><input type=\"file\" name=\"import_file\" id=\"import_file\" /></form>"
77
+ result = "<form class=\"import\" enctype=\"multipart/form-data\" action=\"import_url\" accept-charset=\"UTF-8\" method=\"post\"><input type=\"file\" name=\"import_file\" id=\"import_file\" /></form>"
78
78
  expect(subject.import_form).to eq(result)
79
79
  end
80
80
  end
@@ -2,7 +2,7 @@ require "rails_helper"
2
2
 
3
3
  describe Releaf::I18nDatabase::Translations::TableBuilder, type: :class do
4
4
  class TableBuilderTestHelper < ActionView::Base; end
5
- let(:template){ TableBuilderTestHelper.new }
5
+ let(:template){ TableBuilderTestHelper.new(ActionView::LookupContext.new(nil), {}, nil) }
6
6
  let(:resource_class){ Releaf::I18nDatabase::I18nEntry }
7
7
  let(:subject){ described_class.new([], resource_class, template, {}) }
8
8
 
@@ -34,19 +34,19 @@ describe Releaf::I18nDatabase::TranslationsController do
34
34
 
35
35
  context "when searching" do
36
36
  it "searches by translation key" do
37
- get :index, search: 'great'
37
+ get :index, params: {search: 'great'}
38
38
  expect( assigns(:collection).size ).to eq(1)
39
39
  end
40
40
 
41
41
  it "searched by localized values" do
42
- get :index, search: 'manta'
42
+ get :index, params: {search: 'manta'}
43
43
  expect( assigns(:collection).size ).to eq(1)
44
44
  end
45
45
  end
46
46
 
47
47
  context "when searching blank translations" do
48
48
  it "returns translations that has blank translation in any localization" do
49
- get :index, only_blank: 'true'
49
+ get :index, params: {only_blank: 'true'}
50
50
  expect( assigns(:collection).map(&:id) ).to match_array [@t1.id]
51
51
  end
52
52
  end
@@ -62,7 +62,7 @@ describe Releaf::I18nDatabase::TranslationsController do
62
62
 
63
63
  context "when search scope is given" do
64
64
  it "renders translations matching search pattern" do
65
- get :index, search: 'stuff'
65
+ get :index, params: {search: 'stuff'}
66
66
  expect( assigns(:collection).size ).to eq(2)
67
67
  end
68
68
  end
@@ -72,12 +72,12 @@ describe Releaf::I18nDatabase::TranslationsController do
72
72
  context "when save successful" do
73
73
  it "updates translations updated_at" do
74
74
  expect(Releaf::I18nDatabase::Backend).to receive("translations_updated_at=").with(@time_now)
75
- put :update, translations: [{key: 'a.b.c', localizations: {en: 'test', lv: 'xxl'}}]
75
+ put :update, params: {translations: [{key: 'a.b.c', localizations: {en: 'test', lv: 'xxl'}}]}
76
76
  end
77
77
 
78
78
  context "when save with import" do
79
79
  before do
80
- put :update, translations: [{key: 'a.b.c', localizations: {en: 'test', lv: 'xxl'}}], import: "true"
80
+ put :update, params: {translations: [{key: 'a.b.c', localizations: {en: 'test', lv: 'xxl'}}], import: "true"}
81
81
  end
82
82
 
83
83
  it "redirects to index view" do
@@ -91,7 +91,7 @@ describe Releaf::I18nDatabase::TranslationsController do
91
91
 
92
92
  context "when save without import" do
93
93
  before do
94
- put :update, translations: [{key: 'a.b.c', localizations: {en: 'test', lv: 'xxl'}}]
94
+ put :update, params: {translations: [{key: 'a.b.c', localizations: {en: 'test', lv: 'xxl'}}]}
95
95
  end
96
96
 
97
97
  it "redirects to edit view" do
@@ -106,12 +106,12 @@ describe Releaf::I18nDatabase::TranslationsController do
106
106
 
107
107
  context "when save failed" do
108
108
  it "renders edit view" do
109
- put :update, translations: [{key: '', localizations: {en: 'test', lv: 'xxl'}}]
109
+ put :update, params: {translations: [{key: '', localizations: {en: 'test', lv: 'xxl'}}]}
110
110
  expect(response).to render_template(:edit)
111
111
  end
112
112
 
113
113
  it "flash error notification" do
114
- put :update, translations: [{key: '', localizations: {en: 'test', lv: 'xxl'}}]
114
+ put :update, params: {translations: [{key: '', localizations: {en: 'test', lv: 'xxl'}}]}
115
115
  expect(flash["error"]).to eq("id" => "resource_status", "message" => "Update failed")
116
116
  end
117
117
  end
@@ -122,7 +122,7 @@ describe Releaf::I18nDatabase::TranslationsController do
122
122
  before do
123
123
  file = fixture_file_upload(File.expand_path('../../fixtures/translations_import.xlsx', __dir__),
124
124
  'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
125
- post :import, import_file: file
125
+ post :import, params: {import_file: file}
126
126
  end
127
127
 
128
128
  it "parses uploaded file and assigns content to collection" do
@@ -357,7 +357,7 @@ feature "Translations" do
357
357
 
358
358
  context "when positive create_plurals option passed" do
359
359
  it "creates pluralized translations for all Releaf locales" do
360
- result = ["animals.horse.few", "animals.horse.many", "animals.horse.one", "animals.horse.other", "animals.horse.zero"]
360
+ result = ["animals.horse.one", "animals.horse.other", "animals.horse.zero"]
361
361
  expect{ I18n.t("animals.horse", count: 1, create_plurals: true) }.to change{ Releaf::I18nDatabase::I18nEntry.pluck(:key).sort }.
362
362
  from([]).to(result.sort)
363
363
  end
@@ -3,7 +3,6 @@ require "rails_helper"
3
3
  describe Releaf::I18nDatabase::ParseSpreadsheetTranslations do
4
4
  let(:translation){ Releaf::I18nDatabase::I18nEntry.new }
5
5
  let(:fixture_path){ File.expand_path('../../../fixtures/translations_import.xlsx', __dir__) }
6
- let(:error_message){ "Don't know how to open file #{fixture_path}" }
7
6
  subject{ described_class.new(file_path: fixture_path, extension: "xlsx") }
8
7
 
9
8
  describe "#call" do
@@ -82,9 +81,9 @@ describe Releaf::I18nDatabase::ParseSpreadsheetTranslations do
82
81
  describe "#file_format_error?" do
83
82
 
84
83
  context "when given error is an ArgumentError" do
85
- context "when the message contains 'Don't know how to open file'" do
84
+ context "when the message contains 'Can't detect the type'" do
86
85
  it "returns true" do
87
- expect(subject.file_format_error?("ArgumentError", error_message)).to be true
86
+ expect(subject.file_format_error?("ArgumentError", "Can't detect the type")).to be true
88
87
  end
89
88
  end
90
89
  context "when the message is different" do
@@ -94,9 +93,9 @@ describe Releaf::I18nDatabase::ParseSpreadsheetTranslations do
94
93
  end
95
94
  end
96
95
 
97
- context "when the error is a Zip::ZipError" do
96
+ context "when the error is a Zip::Error" do
98
97
  it "returns true" do
99
- expect(subject.file_format_error?("Zip::ZipError", "error message")).to be true
98
+ expect(subject.file_format_error?("Zip::Error", "error message")).to be true
100
99
  end
101
100
  end
102
101
 
@@ -3,7 +3,7 @@ require "rails_helper"
3
3
  describe Releaf::I18nDatabase::I18nEntry do
4
4
  it { is_expected.to validate_presence_of(:key) }
5
5
  it { is_expected.to validate_length_of(:key).is_at_most(255) }
6
- it { is_expected.to validate_uniqueness_of(:key) }
6
+ it { subject.key = "a"; is_expected.to validate_uniqueness_of(:key) }
7
7
  it { is_expected.to have_many(:i18n_entry_translation).dependent(:destroy) }
8
8
  it { is_expected.to accept_nested_attributes_for(:i18n_entry_translation).allow_destroy(true) }
9
9
 
@@ -4,6 +4,6 @@ describe Releaf::I18nDatabase::I18nEntryTranslation do
4
4
  it { is_expected.to validate_presence_of(:i18n_entry) }
5
5
  it { is_expected.to validate_presence_of(:locale) }
6
6
  it { is_expected.to validate_length_of(:locale).is_at_most(5) }
7
- it { subject.locale = "de"; is_expected.to validate_uniqueness_of(:i18n_entry_id).scoped_to([:locale]) }
7
+ it { subject.locale = "de"; subject.i18n_entry_id = 1; is_expected.to validate_uniqueness_of(:i18n_entry_id).scoped_to([:locale]) }
8
8
  it { is_expected.to belong_to(:i18n_entry) }
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: releaf-i18n_database
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.22
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - CubeSystems
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-26 00:00:00.000000000 Z
11
+ date: 2020-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: releaf-core
@@ -16,48 +16,42 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 1.1.22
19
+ version: 2.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 1.1.22
26
+ version: 2.0.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rails-i18n
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 4.0.0
33
+ version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 4.0.0
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: axlsx_rails
42
+ name: caxlsx_rails
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: 0.3.0
48
45
  - - "~>"
49
46
  - !ruby/object:Gem::Version
50
- version: '0.3'
47
+ version: '0.6'
51
48
  type: :runtime
52
49
  prerelease: false
53
50
  version_requirements: !ruby/object:Gem::Requirement
54
51
  requirements:
55
- - - ">="
56
- - !ruby/object:Gem::Version
57
- version: 0.3.0
58
52
  - - "~>"
59
53
  - !ruby/object:Gem::Version
60
- version: '0.3'
54
+ version: '0.6'
61
55
  - !ruby/object:Gem::Dependency
62
56
  name: roo
63
57
  requirement: !ruby/object:Gem::Requirement
@@ -79,6 +73,7 @@ extensions: []
79
73
  extra_rdoc_files: []
80
74
  files:
81
75
  - LICENSE
76
+ - app/assets/config/releaf_i18n_database_manifest.js
82
77
  - app/assets/javascripts/controllers/releaf/i18n_database/translations.js
83
78
  - app/assets/stylesheets/controllers/releaf/i18n_database/translations.scss
84
79
  - app/builders/releaf/i18n_database/translations/builders_common.rb
@@ -123,7 +118,7 @@ homepage: https://github.com/cubesystems/releaf
123
118
  licenses:
124
119
  - MIT
125
120
  metadata: {}
126
- post_install_message:
121
+ post_install_message:
127
122
  rdoc_options: []
128
123
  require_paths:
129
124
  - lib
@@ -138,8 +133,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
133
  - !ruby/object:Gem::Version
139
134
  version: '0'
140
135
  requirements: []
141
- rubygems_version: 3.0.4
142
- signing_key:
136
+ rubygems_version: 3.0.8
137
+ signing_key:
143
138
  specification_version: 4
144
139
  summary: i18n database gem for releaf
145
140
  test_files: