lolita-translation 0.6.3 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Gemfile +13 -1
- data/README.md +4 -4
- data/Rakefile +3 -1
- data/app/assets/javascripts/lolita/translation/application.js +1 -2
- data/lib/lolita-translation/builder/abstract_builder.rb +5 -5
- data/lib/lolita-translation/builder/active_record_builder.rb +13 -14
- data/lib/lolita-translation/configuration.rb +4 -4
- data/lib/lolita-translation/locales.rb +2 -2
- data/lib/lolita-translation/lolita/component_hooks.rb +6 -6
- data/lib/lolita-translation/record.rb +9 -9
- data/lib/lolita-translation/version.rb +2 -2
- data/lolita-translation.gemspec +2 -13
- data/spec/features/record_language_switch_spec.rb +13 -0
- data/spec/{requests → features}/record_saving_spec.rb +10 -10
- data/spec/integrations/active_record_integration_spec.rb +38 -39
- data/spec/lolita-translation/builder/abstract_builder_spec.rb +6 -14
- data/spec/lolita-translation/builder/active_record_builder_spec.rb +6 -12
- data/spec/lolita-translation/configuration_spec.rb +16 -20
- data/spec/lolita-translation/locales_spec.rb +6 -6
- data/spec/lolita-translation/lolita/tab_extension_spec.rb +2 -2
- data/spec/lolita-translation/migrator_spec.rb +11 -16
- data/spec/lolita-translation/migrators/active_record_migrator_spec.rb +7 -12
- data/spec/rails_helper.rb +2 -2
- data/spec/spec_helper.rb +9 -23
- data/spec/tasks/lolita_translation_spec.rb +5 -10
- data/spec/test_app/app/models/post.rb +1 -0
- metadata +11 -165
- data/spec/requests/record_language_switch_spec.rb +0 -16
@@ -2,25 +2,20 @@ require 'spec_helper'
|
|
2
2
|
require 'ar_schema'
|
3
3
|
ARSchema.connect!
|
4
4
|
|
5
|
-
describe Lolita::Translation::Migrators::ActiveRecordMigrator do
|
5
|
+
describe Lolita::Translation::Migrators::ActiveRecordMigrator do
|
6
6
|
let(:klass){ Lolita::Translation::Migrators::ActiveRecordMigrator }
|
7
7
|
|
8
|
-
before(:each) do
|
9
|
-
Object.send(:remove_const,:Comment) rescue nil
|
8
|
+
before(:each) do
|
10
9
|
c_class = Class.new(ActiveRecord::Base)
|
11
|
-
|
12
|
-
c_class.class_eval do
|
10
|
+
stub_const('Comment',c_class)
|
11
|
+
c_class.class_eval do
|
13
12
|
include Lolita::Translation
|
14
13
|
translate :body
|
15
14
|
end
|
16
15
|
ActiveRecord::Base.connection.execute("DROP TABLE comments_translations") rescue nil
|
17
16
|
end
|
18
17
|
|
19
|
-
|
20
|
-
Object.send(:remove_const,:Comment) rescue nil
|
21
|
-
end
|
22
|
-
|
23
|
-
it "should create new table for class" do
|
18
|
+
it "should create new table for class" do
|
24
19
|
migrator = klass.new(Comment)
|
25
20
|
ActiveRecord::Base.connection.tables.should_not include("comments_translations")
|
26
21
|
migrator.migrate
|
@@ -28,7 +23,7 @@ describe Lolita::Translation::Migrators::ActiveRecordMigrator do
|
|
28
23
|
CommentTranslation.column_names.sort.should eq(%w(body locale comment_id id).sort)
|
29
24
|
end
|
30
25
|
|
31
|
-
it "should add new column to table when one is added to configuration" do
|
26
|
+
it "should add new column to table when one is added to configuration" do
|
32
27
|
migrator = klass.new(Comment)
|
33
28
|
ActiveRecord::Base.connection.tables.should_not include("comments_translations")
|
34
29
|
migrator.migrate
|
@@ -38,7 +33,7 @@ describe Lolita::Translation::Migrators::ActiveRecordMigrator do
|
|
38
33
|
CommentTranslation.column_names.sort.should eq(%w(body locale comment_id id commenter).sort)
|
39
34
|
end
|
40
35
|
|
41
|
-
it "should remove column from table if it is removed from configuration" do
|
36
|
+
it "should remove column from table if it is removed from configuration" do
|
42
37
|
migrator = klass.new(Comment)
|
43
38
|
Comment.translations_configuration.attributes << :commenter
|
44
39
|
migrator.migrate
|
data/spec/rails_helper.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,31 +1,20 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
# Now there are support only for "active_record"
|
3
3
|
ENV["ORM"] = "active_record"
|
4
|
-
# Set this to true if you want to launch rails application
|
5
|
-
USE_RAILS = true
|
6
|
-
# Set this true to use debugger, if your ruby version supports debugger.
|
7
|
-
USE_DEBUGGER = true
|
8
|
-
# Set this to true to see HTML code coverage report
|
9
|
-
SHOW_REPORT = false
|
10
|
-
|
11
4
|
|
12
5
|
require 'header'
|
13
|
-
if USE_RAILS
|
14
|
-
require 'rails_helper'
|
15
|
-
end
|
16
6
|
|
17
7
|
if ENV["ORM"] == "active_record"
|
18
8
|
require 'ar_schema'
|
19
9
|
end
|
20
10
|
|
21
|
-
|
22
|
-
|
11
|
+
require 'rails_helper'
|
12
|
+
|
13
|
+
unless ENV['CI']
|
14
|
+
require 'byebug'
|
23
15
|
end
|
24
16
|
|
25
17
|
require 'logger'
|
26
|
-
require 'ffaker'
|
27
|
-
require File.expand_path('lib/lolita-translation')
|
28
|
-
|
29
18
|
|
30
19
|
# setup I18n
|
31
20
|
I18n.available_locales = [:en,:lv,:ru,:fr]
|
@@ -41,16 +30,13 @@ RSpec.configure do |config|
|
|
41
30
|
end
|
42
31
|
config.treat_symbols_as_metadata_keys_with_true_values = true
|
43
32
|
config.mock_with :rspec
|
33
|
+
config.order = 'rand:3455'
|
34
|
+
config.use_transactional_fixtures = true
|
44
35
|
end
|
45
36
|
end
|
46
37
|
|
47
|
-
at_exit do
|
48
|
-
if
|
49
|
-
|
50
|
-
File.delete(File.expand_path("spec/test_app/db/lolita-translation.db"))
|
51
|
-
end
|
52
|
-
end
|
53
|
-
if ::SHOW_REPORT
|
54
|
-
CoverMe.complete!
|
38
|
+
at_exit do
|
39
|
+
if File.exist?(File.expand_path("spec/test_app/db/lolita-translation.db"))
|
40
|
+
File.delete(File.expand_path("spec/test_app/db/lolita-translation.db"))
|
55
41
|
end
|
56
42
|
end
|
@@ -2,27 +2,22 @@ require 'spec_helper'
|
|
2
2
|
require 'ar_schema'
|
3
3
|
ARSchema.connect!
|
4
4
|
|
5
|
-
describe "lolita_translation:sync_tables" do
|
5
|
+
describe "lolita_translation:sync_tables" do
|
6
6
|
def translations
|
7
7
|
ActiveRecord::Base.connection.tables.reject{|tn| !tn.match(/translations/)}.sort
|
8
8
|
end
|
9
9
|
|
10
|
-
before(:each) do
|
11
|
-
Object.send(:remove_const,:Comment) rescue nil
|
10
|
+
before(:each) do
|
12
11
|
c_class = Class.new(ActiveRecord::Base)
|
13
|
-
|
14
|
-
c_class.class_eval do
|
12
|
+
stub_const('Comment',c_class)
|
13
|
+
c_class.class_eval do
|
15
14
|
include Lolita::Translation
|
16
15
|
translate :body
|
17
16
|
end
|
18
17
|
ActiveRecord::Base.connection.execute("DROP TABLE comments_translations") rescue nil
|
19
18
|
end
|
20
19
|
|
21
|
-
|
22
|
-
Object.send(:remove_const,:Comment) rescue nil
|
23
|
-
end
|
24
|
-
|
25
|
-
it "should create translation tables for all lolita mappings" do
|
20
|
+
it "should create translation tables for all lolita mappings" do
|
26
21
|
translations.should eq(%w(categories_translations posts_translations products_translations).sort)
|
27
22
|
Lolita.mappings[:comment] = Lolita::Mapping.new(:comments)
|
28
23
|
load(File.expand_path("lib/tasks/lolita_translation.rake"))
|
metadata
CHANGED
@@ -1,176 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lolita-translation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.7.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- ITHouse (Latvia) and Arturs Meisters
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2013-07-10 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: lolita
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - ~>
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version: 3.2
|
19
|
+
version: '3.2'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - ~>
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version: 3.2
|
30
|
-
- !ruby/object:Gem::Dependency
|
31
|
-
name: rails
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
|
-
requirements:
|
35
|
-
- - ~>
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version: 3.2.3
|
38
|
-
type: :development
|
39
|
-
prerelease: false
|
40
|
-
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - ~>
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: 3.2.3
|
46
|
-
- !ruby/object:Gem::Dependency
|
47
|
-
name: rspec
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
|
-
requirements:
|
51
|
-
- - ~>
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: 2.9.0
|
54
|
-
type: :development
|
55
|
-
prerelease: false
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
|
-
requirements:
|
59
|
-
- - ~>
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: 2.9.0
|
62
|
-
- !ruby/object:Gem::Dependency
|
63
|
-
name: rspec-rails
|
64
|
-
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
|
-
requirements:
|
67
|
-
- - ~>
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: 2.9.0
|
70
|
-
type: :development
|
71
|
-
prerelease: false
|
72
|
-
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
|
-
requirements:
|
75
|
-
- - ~>
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version: 2.9.0
|
78
|
-
- !ruby/object:Gem::Dependency
|
79
|
-
name: ffaker
|
80
|
-
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
|
-
requirements:
|
83
|
-
- - ~>
|
84
|
-
- !ruby/object:Gem::Version
|
85
|
-
version: '1'
|
86
|
-
type: :development
|
87
|
-
prerelease: false
|
88
|
-
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
|
-
requirements:
|
91
|
-
- - ~>
|
92
|
-
- !ruby/object:Gem::Version
|
93
|
-
version: '1'
|
94
|
-
- !ruby/object:Gem::Dependency
|
95
|
-
name: capybara
|
96
|
-
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
|
-
requirements:
|
99
|
-
- - ~>
|
100
|
-
- !ruby/object:Gem::Version
|
101
|
-
version: 1.1.2
|
102
|
-
type: :development
|
103
|
-
prerelease: false
|
104
|
-
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
|
-
requirements:
|
107
|
-
- - ~>
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
version: 1.1.2
|
110
|
-
- !ruby/object:Gem::Dependency
|
111
|
-
name: capybara-webkit
|
112
|
-
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
|
-
requirements:
|
115
|
-
- - ~>
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: 0.11.0
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
|
-
requirements:
|
123
|
-
- - ~>
|
124
|
-
- !ruby/object:Gem::Version
|
125
|
-
version: 0.11.0
|
126
|
-
- !ruby/object:Gem::Dependency
|
127
|
-
name: cover_me
|
128
|
-
requirement: !ruby/object:Gem::Requirement
|
129
|
-
none: false
|
130
|
-
requirements:
|
131
|
-
- - ~>
|
132
|
-
- !ruby/object:Gem::Version
|
133
|
-
version: 1.2.0
|
134
|
-
type: :development
|
135
|
-
prerelease: false
|
136
|
-
version_requirements: !ruby/object:Gem::Requirement
|
137
|
-
none: false
|
138
|
-
requirements:
|
139
|
-
- - ~>
|
140
|
-
- !ruby/object:Gem::Version
|
141
|
-
version: 1.2.0
|
142
|
-
- !ruby/object:Gem::Dependency
|
143
|
-
name: sqlite3
|
144
|
-
requirement: !ruby/object:Gem::Requirement
|
145
|
-
none: false
|
146
|
-
requirements:
|
147
|
-
- - ~>
|
148
|
-
- !ruby/object:Gem::Version
|
149
|
-
version: 1.3.6
|
150
|
-
type: :development
|
151
|
-
prerelease: false
|
152
|
-
version_requirements: !ruby/object:Gem::Requirement
|
153
|
-
none: false
|
154
|
-
requirements:
|
155
|
-
- - ~>
|
156
|
-
- !ruby/object:Gem::Version
|
157
|
-
version: 1.3.6
|
158
|
-
- !ruby/object:Gem::Dependency
|
159
|
-
name: debugger
|
160
|
-
requirement: !ruby/object:Gem::Requirement
|
161
|
-
none: false
|
162
|
-
requirements:
|
163
|
-
- - ! '>'
|
164
|
-
- !ruby/object:Gem::Version
|
165
|
-
version: '0'
|
166
|
-
type: :development
|
167
|
-
prerelease: false
|
168
|
-
version_requirements: !ruby/object:Gem::Requirement
|
169
|
-
none: false
|
170
|
-
requirements:
|
171
|
-
- - ! '>'
|
172
|
-
- !ruby/object:Gem::Version
|
173
|
-
version: '0'
|
26
|
+
version: '3.2'
|
174
27
|
description: Lolita extension that allow users to change language and translate DB
|
175
28
|
data.
|
176
29
|
email: support@ithouse.lv
|
@@ -218,6 +71,8 @@ files:
|
|
218
71
|
- lib/tasks/lolita_translation.rake
|
219
72
|
- lolita-translation.gemspec
|
220
73
|
- spec/ar_schema.rb
|
74
|
+
- spec/features/record_language_switch_spec.rb
|
75
|
+
- spec/features/record_saving_spec.rb
|
221
76
|
- spec/header.rb
|
222
77
|
- spec/integrations/active_record_integration_spec.rb
|
223
78
|
- spec/lolita-translation/builder/abstract_builder_spec.rb
|
@@ -233,8 +88,6 @@ files:
|
|
233
88
|
- spec/lolita-translation/translation_class_builder_spec.rb
|
234
89
|
- spec/lolita_translation_spec.rb
|
235
90
|
- spec/rails_helper.rb
|
236
|
-
- spec/requests/record_language_switch_spec.rb
|
237
|
-
- spec/requests/record_saving_spec.rb
|
238
91
|
- spec/spec_helper.rb
|
239
92
|
- spec/tasks/lolita_translation_spec.rb
|
240
93
|
- spec/test_app/app/controllers/application_controller.rb
|
@@ -253,32 +106,25 @@ files:
|
|
253
106
|
homepage: http://github.com/ithouse/lolita-translation
|
254
107
|
licenses:
|
255
108
|
- MIT
|
109
|
+
metadata: {}
|
256
110
|
post_install_message:
|
257
111
|
rdoc_options: []
|
258
112
|
require_paths:
|
259
113
|
- lib
|
260
114
|
required_ruby_version: !ruby/object:Gem::Requirement
|
261
|
-
none: false
|
262
115
|
requirements:
|
263
|
-
- -
|
116
|
+
- - '>='
|
264
117
|
- !ruby/object:Gem::Version
|
265
118
|
version: '0'
|
266
|
-
segments:
|
267
|
-
- 0
|
268
|
-
hash: 2662637262140224186
|
269
119
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
270
|
-
none: false
|
271
120
|
requirements:
|
272
|
-
- -
|
121
|
+
- - '>='
|
273
122
|
- !ruby/object:Gem::Version
|
274
123
|
version: '0'
|
275
|
-
segments:
|
276
|
-
- 0
|
277
|
-
hash: 2662637262140224186
|
278
124
|
requirements: []
|
279
125
|
rubyforge_project:
|
280
|
-
rubygems_version:
|
126
|
+
rubygems_version: 2.0.3
|
281
127
|
signing_key:
|
282
|
-
specification_version:
|
128
|
+
specification_version: 4
|
283
129
|
summary: Lolita extension that add multilanguate support to Lolita.
|
284
130
|
test_files: []
|
@@ -1,16 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
if USE_RAILS
|
4
|
-
describe "In order to translate resource As system user I want to switch from original resource to translations" do
|
5
|
-
|
6
|
-
it "As user in resource create form I see language switch and current language is active and I can switch to other languages" do
|
7
|
-
visit "/lolita/posts/new"
|
8
|
-
language_selector_text = page.find(".tab-language-switch").text
|
9
|
-
::I18n.available_locales.each do |locale|
|
10
|
-
language_selector_text.should match(/#{locale.to_s.capitalize}/)
|
11
|
-
end
|
12
|
-
|
13
|
-
end
|
14
|
-
|
15
|
-
end
|
16
|
-
end
|