copy_tuner_client 0.5.2 → 0.8.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 +5 -5
- data/.github/workflows/rspec.yml +53 -0
- data/.ruby-version +1 -1
- data/CHANGELOG.md +21 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +157 -159
- data/Rakefile +0 -10
- data/copy_tuner_client.gemspec +3 -6
- data/gemfiles/5.2.gemfile +1 -1
- data/gemfiles/{5.0.gemfile → 6.0.gemfile} +1 -1
- data/lib/copy_tuner_client/cache.rb +2 -0
- data/lib/copy_tuner_client/configuration.rb +10 -2
- data/lib/copy_tuner_client/engine.rb +7 -3
- data/lib/copy_tuner_client/translation_log.rb +3 -4
- data/lib/copy_tuner_client/version.rb +1 -1
- data/lib/tasks/copy_tuner_client_tasks.rake +4 -4
- data/spec/copy_tuner_client/process_guard_spec.rb +2 -1
- metadata +12 -68
- data/.travis.yml +0 -19
- data/Appraisals +0 -11
- data/features/rails.feature +0 -284
- data/features/step_definitions/copycopter_server_steps.rb +0 -64
- data/features/step_definitions/rails_steps.rb +0 -187
- data/features/support/env.rb +0 -11
- data/features/support/rails_server.rb +0 -150
- data/gemfiles/5.1.gemfile +0 -7
- data/init.rb +0 -1
data/Rakefile
CHANGED
@@ -1,6 +1,4 @@
|
|
1
1
|
require 'bundler/gem_tasks'
|
2
|
-
require 'appraisal'
|
3
|
-
require 'cucumber/rake/task'
|
4
2
|
require 'rspec/core/rake_task'
|
5
3
|
require 'yard'
|
6
4
|
|
@@ -13,14 +11,6 @@ RSpec::Core::RakeTask.new do |t|
|
|
13
11
|
t.pattern = 'spec/copy_tuner_client/**/*_spec.rb'
|
14
12
|
end
|
15
13
|
|
16
|
-
desc 'Run cucumber features'
|
17
|
-
Cucumber::Rake::Task.new do |t|
|
18
|
-
t.cucumber_opts = [
|
19
|
-
'--tags', '~@wip',
|
20
|
-
'--format', (ENV['CUCUMBER_FORMAT'] || 'progress')
|
21
|
-
]
|
22
|
-
end
|
23
|
-
|
24
14
|
YARD::Rake::YardocTask.new do |t|
|
25
15
|
t.files = ['lib/**/*.rb']
|
26
16
|
end
|
data/copy_tuner_client.gemspec
CHANGED
@@ -3,15 +3,12 @@ $LOAD_PATH.push File.expand_path('../lib', __FILE__)
|
|
3
3
|
require 'copy_tuner_client/version'
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
|
-
s.required_ruby_version = '>= 2.
|
6
|
+
s.required_ruby_version = '>= 2.5.0'
|
7
7
|
s.add_dependency 'i18n', '>= 0.5.0'
|
8
8
|
s.add_dependency 'json'
|
9
|
-
s.add_development_dependency '
|
10
|
-
s.add_development_dependency 'aruba', '~> 0.6.0'
|
11
|
-
s.add_development_dependency 'cucumber', '~> 1.3.16'
|
12
|
-
s.add_development_dependency 'rails', '~> 4.2.6'
|
9
|
+
s.add_development_dependency 'rails', '~> 5.2.4.2'
|
13
10
|
s.add_development_dependency 'rake'
|
14
|
-
s.add_development_dependency 'rspec'
|
11
|
+
s.add_development_dependency 'rspec', '3.8.0' # NOTE: 3.9.0だとundefined method `synchronize'でコケるテストがある
|
15
12
|
s.add_development_dependency 'sham_rack'
|
16
13
|
s.add_development_dependency 'sinatra'
|
17
14
|
s.add_development_dependency 'sqlite3'
|
data/gemfiles/5.2.gemfile
CHANGED
@@ -17,6 +17,7 @@ module CopyTunerClient
|
|
17
17
|
@logger = options[:logger]
|
18
18
|
@mutex = Mutex.new
|
19
19
|
@exclude_key_regexp = options[:exclude_key_regexp]
|
20
|
+
@upload_disabled = options[:upload_disabled]
|
20
21
|
@locales = Array(options[:locales]).map(&:to_s)
|
21
22
|
# mutable states
|
22
23
|
@blurbs = {}
|
@@ -41,6 +42,7 @@ module CopyTunerClient
|
|
41
42
|
return if @exclude_key_regexp && key.match?(@exclude_key_regexp)
|
42
43
|
return unless key.include?('.')
|
43
44
|
return if @locales.present? && !@locales.member?(key.split('.').first)
|
45
|
+
return if @upload_disabled
|
44
46
|
|
45
47
|
lock do
|
46
48
|
return if @blank_keys.member?(key) || @blurbs.key?(key)
|
@@ -57,6 +57,9 @@ module CopyTunerClient
|
|
57
57
|
# @return [Array<String>] A list of environments in which the server should not be contacted
|
58
58
|
attr_accessor :test_environments
|
59
59
|
|
60
|
+
# @return [Array<String>] A list of environments in which the server should not be upload
|
61
|
+
attr_accessor :upload_disabled_environments
|
62
|
+
|
60
63
|
# @return [String] The name of the environment the application is running in
|
61
64
|
attr_accessor :environment_name
|
62
65
|
|
@@ -145,6 +148,7 @@ module CopyTunerClient
|
|
145
148
|
self.sync_interval_staging = 0
|
146
149
|
self.secure = true
|
147
150
|
self.test_environments = %w(test cucumber)
|
151
|
+
self.upload_disabled_environments = %w[production staging]
|
148
152
|
self.s3_host = 'copy-tuner-data-prod.s3.amazonaws.com'
|
149
153
|
self.disable_copyray_comment_injection = false
|
150
154
|
self.html_escape = false
|
@@ -163,7 +167,7 @@ module CopyTunerClient
|
|
163
167
|
# Returns a hash of all configurable options
|
164
168
|
# @return [Hash] configuration attributes
|
165
169
|
def to_hash
|
166
|
-
base_options = { :public
|
170
|
+
base_options = { public: public?, upload_disabled: upload_disabled? }
|
167
171
|
|
168
172
|
OPTIONS.inject(base_options) do |hash, option|
|
169
173
|
hash.merge option.to_sym => send(option)
|
@@ -198,7 +202,11 @@ module CopyTunerClient
|
|
198
202
|
# Determines if the content will fetched from the server
|
199
203
|
# @return [Boolean] Returns +true+ if in a test environment, +false+ otherwise.
|
200
204
|
def test?
|
201
|
-
test_environments.include?
|
205
|
+
test_environments.include?(environment_name)
|
206
|
+
end
|
207
|
+
|
208
|
+
def upload_disabled?
|
209
|
+
upload_disabled_environments.include?(environment_name)
|
202
210
|
end
|
203
211
|
|
204
212
|
# Determines if the configuration has been applied (internal)
|
@@ -13,7 +13,13 @@ module CopyTunerClient
|
|
13
13
|
ActionView::Helpers::TranslationHelper.class_eval do
|
14
14
|
def translate_with_copyray_comment(key, options = {})
|
15
15
|
source = translate_without_copyray_comment(key, options)
|
16
|
-
|
16
|
+
# TODO: 0.6.0以降で options[:rescue_format] == text を消す
|
17
|
+
if CopyTunerClient.configuration.disable_copyray_comment_injection || options[:rescue_format] == :text
|
18
|
+
if options[:rescue_format] == :text
|
19
|
+
ActiveSupport::Deprecation.warn('rescue_format option is deprecated in copy_tuner_client@0.6.0')
|
20
|
+
end
|
21
|
+
source
|
22
|
+
else
|
17
23
|
separator = options[:separator] || I18n.default_separator
|
18
24
|
scope = options[:scope]
|
19
25
|
normalized_key =
|
@@ -23,8 +29,6 @@ module CopyTunerClient
|
|
23
29
|
I18n.normalize_keys(nil, key, scope, separator).join(separator)
|
24
30
|
end
|
25
31
|
CopyTunerClient::Copyray.augment_template(source, normalized_key)
|
26
|
-
else
|
27
|
-
source
|
28
32
|
end
|
29
33
|
end
|
30
34
|
if CopyTunerClient.configuration.enable_middleware?
|
@@ -19,12 +19,10 @@ module CopyTunerClient
|
|
19
19
|
def self.install_hook
|
20
20
|
I18n.class_eval do
|
21
21
|
class << self
|
22
|
-
def translate_with_copy_tuner_hook(
|
23
|
-
key = args[0]
|
24
|
-
options = args.last.is_a?(Hash) ? args.last : {}
|
22
|
+
def translate_with_copy_tuner_hook(key, **options)
|
25
23
|
scope = options[:scope]
|
26
24
|
scope = scope.dup if scope.is_a?(Array) || scope.is_a?(String)
|
27
|
-
result = translate_without_copy_tuner_hook(
|
25
|
+
result = translate_without_copy_tuner_hook(key, **options)
|
28
26
|
|
29
27
|
if key.is_a?(Array)
|
30
28
|
key.zip(result).each { |k, v| CopyTunerClient::TranslationLog.add(I18n.normalize_keys(nil, k, scope).join('.'), v) unless v.is_a?(Array) }
|
@@ -33,6 +31,7 @@ module CopyTunerClient
|
|
33
31
|
end
|
34
32
|
result
|
35
33
|
end
|
34
|
+
|
36
35
|
if CopyTunerClient.configuration.enable_middleware?
|
37
36
|
alias_method :translate_without_copy_tuner_hook, :translate
|
38
37
|
alias_method :translate, :translate_with_copy_tuner_hook
|
@@ -6,13 +6,13 @@ namespace :copy_tuner do
|
|
6
6
|
end
|
7
7
|
|
8
8
|
desc "Export CopyTuner blurbs to yaml."
|
9
|
-
task :export => :environment do
|
9
|
+
task :export, %i[path] => :environment do |_, args|
|
10
|
+
args.with_defaults(path: "config/locales/copy_tuner.yml")
|
10
11
|
CopyTunerClient.cache.sync
|
11
12
|
|
12
13
|
if yml = CopyTunerClient.export
|
13
|
-
path
|
14
|
-
|
15
|
-
puts "Successfully exported blurbs to #{path}."
|
14
|
+
File.new("#{Rails.root}/#{args[:path]}", 'w').write(yml)
|
15
|
+
puts "Successfully exported blurbs to #{args[:path]}."
|
16
16
|
else
|
17
17
|
raise "No blurbs have been cached."
|
18
18
|
end
|
@@ -79,7 +79,8 @@ describe CopyTunerClient::ProcessGuard do
|
|
79
79
|
unicorn.spawn
|
80
80
|
end
|
81
81
|
|
82
|
-
|
82
|
+
# FIXME: ruby@2.7以降で失敗するようになっているがテストコードの問題っぽいのでスキップしている
|
83
|
+
xit "flushes when the process terminates" do
|
83
84
|
cache = WritingCache.new
|
84
85
|
pid = fork do
|
85
86
|
process_guard = build_process_guard(cache: cache, preserve_exit_hook: true)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: copy_tuner_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SonicGarden
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-06-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|
@@ -38,62 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: appraisal
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '2.1'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '2.1'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: aruba
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: 0.6.0
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: 0.6.0
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: cucumber
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: 1.3.16
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: 1.3.16
|
83
41
|
- !ruby/object:Gem::Dependency
|
84
42
|
name: rails
|
85
43
|
requirement: !ruby/object:Gem::Requirement
|
86
44
|
requirements:
|
87
45
|
- - "~>"
|
88
46
|
- !ruby/object:Gem::Version
|
89
|
-
version: 4.2
|
47
|
+
version: 5.2.4.2
|
90
48
|
type: :development
|
91
49
|
prerelease: false
|
92
50
|
version_requirements: !ruby/object:Gem::Requirement
|
93
51
|
requirements:
|
94
52
|
- - "~>"
|
95
53
|
- !ruby/object:Gem::Version
|
96
|
-
version: 4.2
|
54
|
+
version: 5.2.4.2
|
97
55
|
- !ruby/object:Gem::Dependency
|
98
56
|
name: rake
|
99
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -112,16 +70,16 @@ dependencies:
|
|
112
70
|
name: rspec
|
113
71
|
requirement: !ruby/object:Gem::Requirement
|
114
72
|
requirements:
|
115
|
-
- -
|
73
|
+
- - '='
|
116
74
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
75
|
+
version: 3.8.0
|
118
76
|
type: :development
|
119
77
|
prerelease: false
|
120
78
|
version_requirements: !ruby/object:Gem::Requirement
|
121
79
|
requirements:
|
122
|
-
- -
|
80
|
+
- - '='
|
123
81
|
- !ruby/object:Gem::Version
|
124
|
-
version:
|
82
|
+
version: 3.8.0
|
125
83
|
- !ruby/object:Gem::Dependency
|
126
84
|
name: sham_rack
|
127
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -214,12 +172,11 @@ extra_rdoc_files: []
|
|
214
172
|
files:
|
215
173
|
- ".babelrc"
|
216
174
|
- ".eslintrc"
|
175
|
+
- ".github/workflows/rspec.yml"
|
217
176
|
- ".gitignore"
|
218
177
|
- ".rspec"
|
219
178
|
- ".rubocop.yml"
|
220
179
|
- ".ruby-version"
|
221
|
-
- ".travis.yml"
|
222
|
-
- Appraisals
|
223
180
|
- CHANGELOG.md
|
224
181
|
- Gemfile
|
225
182
|
- Gemfile.lock
|
@@ -229,15 +186,8 @@ files:
|
|
229
186
|
- app/assets/stylesheets/copyray.css
|
230
187
|
- app/views/_copy_tuner_bar.html.erb
|
231
188
|
- copy_tuner_client.gemspec
|
232
|
-
- features/rails.feature
|
233
|
-
- features/step_definitions/copycopter_server_steps.rb
|
234
|
-
- features/step_definitions/rails_steps.rb
|
235
|
-
- features/support/env.rb
|
236
|
-
- features/support/rails_server.rb
|
237
|
-
- gemfiles/5.0.gemfile
|
238
|
-
- gemfiles/5.1.gemfile
|
239
189
|
- gemfiles/5.2.gemfile
|
240
|
-
-
|
190
|
+
- gemfiles/6.0.gemfile
|
241
191
|
- lib/copy_tuner_client.rb
|
242
192
|
- lib/copy_tuner_client/cache.rb
|
243
193
|
- lib/copy_tuner_client/client.rb
|
@@ -302,24 +252,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
302
252
|
requirements:
|
303
253
|
- - ">="
|
304
254
|
- !ruby/object:Gem::Version
|
305
|
-
version: 2.
|
255
|
+
version: 2.5.0
|
306
256
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
307
257
|
requirements:
|
308
258
|
- - ">="
|
309
259
|
- !ruby/object:Gem::Version
|
310
260
|
version: '0'
|
311
261
|
requirements: []
|
312
|
-
|
313
|
-
rubygems_version: 2.6.14.4
|
262
|
+
rubygems_version: 3.1.2
|
314
263
|
signing_key:
|
315
264
|
specification_version: 4
|
316
265
|
summary: Client for the CopyTuner copy management service
|
317
266
|
test_files:
|
318
|
-
- features/rails.feature
|
319
|
-
- features/step_definitions/copycopter_server_steps.rb
|
320
|
-
- features/step_definitions/rails_steps.rb
|
321
|
-
- features/support/env.rb
|
322
|
-
- features/support/rails_server.rb
|
323
267
|
- spec/copy_tuner_client/cache_spec.rb
|
324
268
|
- spec/copy_tuner_client/client_spec.rb
|
325
269
|
- spec/copy_tuner_client/configuration_spec.rb
|
data/.travis.yml
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
rvm:
|
2
|
-
- 2.4.6
|
3
|
-
- 2.5.5
|
4
|
-
- 2.6.3
|
5
|
-
|
6
|
-
gemfile:
|
7
|
-
- gemfiles/5.0.gemfile
|
8
|
-
- gemfiles/5.1.gemfile
|
9
|
-
- gemfiles/5.2.gemfile
|
10
|
-
|
11
|
-
matrix:
|
12
|
-
exclude:
|
13
|
-
- rvm: 2.6.3
|
14
|
-
gemfile: gemfiles/5.0.gemfile
|
15
|
-
- rvm: 2.6.3
|
16
|
-
gemfile: gemfiles/5.1.gemfile
|
17
|
-
|
18
|
-
before_install:
|
19
|
-
- gem update bundler
|
data/Appraisals
DELETED
data/features/rails.feature
DELETED
@@ -1,284 +0,0 @@
|
|
1
|
-
@disable-bundler
|
2
|
-
Feature: Using copy_tuner in a rails app
|
3
|
-
|
4
|
-
Background:
|
5
|
-
Given I have a copy_tuner project with an api key of "abc123"
|
6
|
-
When I generate a rails application
|
7
|
-
And I configure the copy_tuner client with api key "abc123"
|
8
|
-
|
9
|
-
Scenario: copy_tuner in the controller
|
10
|
-
Given the "abc123" project has the following blurbs:
|
11
|
-
| key | draft content |
|
12
|
-
| en.users.index.controller-test | This is a test |
|
13
|
-
When I write to "app/controllers/users_controller.rb" with:
|
14
|
-
"""
|
15
|
-
class UsersController < ActionController::Base
|
16
|
-
def index
|
17
|
-
@text = t("users.index.controller-test", :default => "default")
|
18
|
-
end
|
19
|
-
end
|
20
|
-
"""
|
21
|
-
When I route the "users" resource
|
22
|
-
And I write to "app/views/users/index.html.erb" with:
|
23
|
-
"""
|
24
|
-
<%= @text %>
|
25
|
-
"""
|
26
|
-
When I start the application
|
27
|
-
And I wait for changes to be synchronized
|
28
|
-
Then the copy_tuner client version and environment should have been logged
|
29
|
-
Then the log should contain "Downloaded translations"
|
30
|
-
When I visit /users/
|
31
|
-
Then the response should contain "This is a test"
|
32
|
-
And I wait for changes to be synchronized
|
33
|
-
And the log should not contain "DEPRECATION WARNING"
|
34
|
-
|
35
|
-
Scenario: copy_tuner in the view
|
36
|
-
Given the "abc123" project has the following blurbs:
|
37
|
-
| key | draft content |
|
38
|
-
| en.users.index.view-test | This is a test |
|
39
|
-
When I write to "app/controllers/users_controller.rb" with:
|
40
|
-
"""
|
41
|
-
class UsersController < ActionController::Base
|
42
|
-
def index
|
43
|
-
render
|
44
|
-
end
|
45
|
-
end
|
46
|
-
"""
|
47
|
-
When I route the "users" resource
|
48
|
-
And I write to "app/views/users/index.html.erb" with:
|
49
|
-
"""
|
50
|
-
<%= t(".view-test", :default => "default") %>
|
51
|
-
"""
|
52
|
-
When I start the application
|
53
|
-
And I wait for changes to be synchronized
|
54
|
-
And I visit /users/
|
55
|
-
Then the response should contain "This is a test"
|
56
|
-
|
57
|
-
Scenario: copy_tuner detects updates to copy
|
58
|
-
Given the "abc123" project has the following blurbs:
|
59
|
-
| key | draft content |
|
60
|
-
| en.users.index.controller-test | Old content |
|
61
|
-
When I write to "app/controllers/users_controller.rb" with:
|
62
|
-
"""
|
63
|
-
class UsersController < ActionController::Base
|
64
|
-
def index
|
65
|
-
@text = t("users.index.controller-test", :default => "default")
|
66
|
-
end
|
67
|
-
end
|
68
|
-
"""
|
69
|
-
When I route the "users" resource
|
70
|
-
And I write to "app/views/users/index.html.erb" with:
|
71
|
-
"""
|
72
|
-
<%= @text %>
|
73
|
-
"""
|
74
|
-
When I start the application
|
75
|
-
And I wait for changes to be synchronized
|
76
|
-
And I visit /users/
|
77
|
-
Then the response should contain "Old content"
|
78
|
-
And I wait for changes to be synchronized
|
79
|
-
When the the following blurbs are updated in the "abc123" project:
|
80
|
-
| key | draft content |
|
81
|
-
| en.users.index.controller-test | New content |
|
82
|
-
And I wait for changes to be synchronized
|
83
|
-
And I visit /users/
|
84
|
-
Then the response should contain "New content"
|
85
|
-
|
86
|
-
Scenario: missing key
|
87
|
-
When I write to "app/controllers/users_controller.rb" with:
|
88
|
-
"""
|
89
|
-
class UsersController < ActionController::Base
|
90
|
-
def index
|
91
|
-
render :action => "index"
|
92
|
-
end
|
93
|
-
end
|
94
|
-
"""
|
95
|
-
When I route the "users" resource
|
96
|
-
And I write to "app/views/users/index.html.erb" with:
|
97
|
-
"""
|
98
|
-
<%= t(".404", :default => "not found") %>
|
99
|
-
"""
|
100
|
-
When I start the application
|
101
|
-
And I wait for changes to be synchronized
|
102
|
-
And I visit /users/
|
103
|
-
Then the response should contain "not found"
|
104
|
-
And I wait for changes to be synchronized
|
105
|
-
And the "abc123" project should have the following blurbs:
|
106
|
-
| key | draft content |
|
107
|
-
| en.users.index.404 | not found |
|
108
|
-
And the log should contain "Uploaded missing translations"
|
109
|
-
|
110
|
-
Scenario: copy_tuner in production
|
111
|
-
Given the "abc123" project has the following blurbs:
|
112
|
-
| key | published content | draft content |
|
113
|
-
| en.users.index.controller-test | This is a test | Extra extra |
|
114
|
-
| en.users.index.unpublished-test | | Extra extra |
|
115
|
-
When I write to "app/controllers/users_controller.rb" with:
|
116
|
-
"""
|
117
|
-
class UsersController < ActionController::Base
|
118
|
-
def index
|
119
|
-
@text = t("users.index.controller-test", :default => "default")
|
120
|
-
@unpublished = t("users.index.unpublished-test", :default => "Unpublished")
|
121
|
-
t("users.index.unknown-test", :default => "Unknown")
|
122
|
-
end
|
123
|
-
end
|
124
|
-
"""
|
125
|
-
When I route the "users" resource
|
126
|
-
And I write to "app/views/users/index.html.erb" with:
|
127
|
-
"""
|
128
|
-
<%= @text %>
|
129
|
-
<%= @unpublished %>
|
130
|
-
"""
|
131
|
-
When I start the application in the "production" environment
|
132
|
-
And I wait for changes to be synchronized
|
133
|
-
And I visit /users/
|
134
|
-
Then the response should contain "This is a test"
|
135
|
-
And the response should contain "Unpublished"
|
136
|
-
And I wait for changes to be synchronized
|
137
|
-
And the "abc123" project should have the following blurbs:
|
138
|
-
| key | draft content |
|
139
|
-
| en.users.index.unknown-test | |
|
140
|
-
|
141
|
-
Scenario: configure a bad api key
|
142
|
-
When I configure the copy_tuner client with api key "bogus"
|
143
|
-
And I start the application
|
144
|
-
And I wait for changes to be synchronized
|
145
|
-
Then the log should contain "Invalid API key: bogus"
|
146
|
-
|
147
|
-
Scenario: deploy
|
148
|
-
Given the "abc123" project has the following blurbs:
|
149
|
-
| key | draft content | published content |
|
150
|
-
| test.one | expected one | unexpected one |
|
151
|
-
| test.two | expected two | unexpected two |
|
152
|
-
When I successfully rake "copy_tuner:deploy"
|
153
|
-
And I wait for changes to be synchronized
|
154
|
-
And the output should contain "Successfully marked all blurbs as published"
|
155
|
-
And I wait for changes to be synchronized
|
156
|
-
Then the "abc123" project should have the following blurbs:
|
157
|
-
| key | draft content | published content |
|
158
|
-
| test.one | expected one | expected one |
|
159
|
-
| test.two | expected two | expected two |
|
160
|
-
|
161
|
-
Scenario: fallback on the simple I18n backend
|
162
|
-
When I write to "config/locales/en.yml" with:
|
163
|
-
"""
|
164
|
-
en:
|
165
|
-
test:
|
166
|
-
key: Hello, %{name}
|
167
|
-
"""
|
168
|
-
When I write to "app/controllers/users_controller.rb" with:
|
169
|
-
"""
|
170
|
-
class UsersController < ActionController::Base
|
171
|
-
def index
|
172
|
-
render :text => t("test.key", :name => 'Joe')
|
173
|
-
end
|
174
|
-
end
|
175
|
-
"""
|
176
|
-
When I route the "users" resource
|
177
|
-
And I start the application
|
178
|
-
And I wait for changes to be synchronized
|
179
|
-
And I visit /users/
|
180
|
-
Then the response should contain "Hello, Joe"
|
181
|
-
When I wait for changes to be synchronized
|
182
|
-
Then the "abc123" project should have the following blurbs:
|
183
|
-
| key | draft content |
|
184
|
-
| en.test.key | Hello, %{name} |
|
185
|
-
|
186
|
-
Scenario: preserve localization keys
|
187
|
-
When I write to "app/controllers/users_controller.rb" with:
|
188
|
-
"""
|
189
|
-
class UsersController < ActionController::Base
|
190
|
-
def index
|
191
|
-
render
|
192
|
-
end
|
193
|
-
end
|
194
|
-
"""
|
195
|
-
When I route the "users" resource
|
196
|
-
And I write to "app/views/users/index.html.erb" with:
|
197
|
-
"""
|
198
|
-
<%= number_to_currency(2.5) %>
|
199
|
-
"""
|
200
|
-
When I start the application
|
201
|
-
And I wait for changes to be synchronized
|
202
|
-
And I visit /users/
|
203
|
-
Then the response should contain "$2.50"
|
204
|
-
When I wait for changes to be synchronized
|
205
|
-
Then the "abc123" project should not have the "en.number.format" blurb
|
206
|
-
|
207
|
-
Scenario: view validation errors
|
208
|
-
When I write to "app/models/user.rb" with:
|
209
|
-
"""
|
210
|
-
class User < ActiveRecord::Base
|
211
|
-
validates_presence_of :name
|
212
|
-
end
|
213
|
-
"""
|
214
|
-
When I write to "db/migrate/1_create_users.rb" with:
|
215
|
-
"""
|
216
|
-
class CreateUsers < ActiveRecord::Migration
|
217
|
-
def self.up
|
218
|
-
create_table :users do |t|
|
219
|
-
t.string :name
|
220
|
-
end
|
221
|
-
end
|
222
|
-
end
|
223
|
-
"""
|
224
|
-
When I write to "app/controllers/users_controller.rb" with:
|
225
|
-
"""
|
226
|
-
class UsersController < ActionController::Base
|
227
|
-
def index
|
228
|
-
@user = User.new
|
229
|
-
@user.valid?
|
230
|
-
render
|
231
|
-
end
|
232
|
-
end
|
233
|
-
"""
|
234
|
-
When I route the "users" resource
|
235
|
-
And I write to "app/views/users/index.html.erb" with:
|
236
|
-
"""
|
237
|
-
<%= @user.errors.full_messages.first %>
|
238
|
-
"""
|
239
|
-
When I successfully rake "db:migrate RAILS_ENV=development"
|
240
|
-
And I configure the copy_tuner client to use published data
|
241
|
-
And I start the application
|
242
|
-
And I wait for changes to be synchronized
|
243
|
-
And I visit /users/
|
244
|
-
Then the response should contain "Name can't be blank"
|
245
|
-
When I wait for changes to be synchronized
|
246
|
-
Then the "abc123" project should have the following error blurbs:
|
247
|
-
| key | draft content |
|
248
|
-
| user.attributes.name.blank | |
|
249
|
-
|
250
|
-
Scenario: ensure keys are synced with short lived processes
|
251
|
-
When I configure the copy_tuner client to have a polling delay of 86400 seconds
|
252
|
-
And I start the application
|
253
|
-
And I wait for changes to be synchronized
|
254
|
-
And I run a short lived process that sets the key "threaded.key" to "all your base" in "development" environment
|
255
|
-
And I wait for changes to be synchronized
|
256
|
-
Then the "abc123" project should have the following blurbs:
|
257
|
-
| key | draft content |
|
258
|
-
| en.threaded.key | all your base |
|
259
|
-
|
260
|
-
Scenario: support pluralization
|
261
|
-
Given I write to "app/controllers/users_controller.rb" with:
|
262
|
-
"""
|
263
|
-
class UsersController < ActionController::Base
|
264
|
-
def index
|
265
|
-
render
|
266
|
-
end
|
267
|
-
end
|
268
|
-
"""
|
269
|
-
And I route the "users" resource
|
270
|
-
And I write to "app/views/users/index.html.erb" with:
|
271
|
-
"""
|
272
|
-
<%= time_ago_in_words(1.hour.ago) %> ago
|
273
|
-
<%= time_ago_in_words(2.hours.ago) %> ago
|
274
|
-
"""
|
275
|
-
When I start the application
|
276
|
-
And I wait for changes to be synchronized
|
277
|
-
And I visit /users/
|
278
|
-
Then the response should contain "1 hour ago"
|
279
|
-
And the response should contain "2 hours ago"
|
280
|
-
When I wait for changes to be synchronized
|
281
|
-
Then the "abc123" project should have the following blurbs:
|
282
|
-
| key | draft content |
|
283
|
-
| en.datetime.distance_in_words.about_x_hours.one | about 1 hour |
|
284
|
-
| en.datetime.distance_in_words.about_x_hours.other | about %{count} hours |
|