localeapp 0.5.2 → 0.6.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.
- data/CHANGELOG.md +6 -7
- data/Gemfile.github_project.rb +2 -2
- data/bin/localeapp +18 -51
- data/features/add.feature +46 -0
- data/features/bad_command.feature +8 -0
- data/features/help.feature +9 -0
- data/features/install.feature +70 -0
- data/features/pull.feature +46 -0
- data/features/push.feature +57 -0
- data/features/update.feature +44 -0
- data/lib/localeapp/cli/add.rb +1 -5
- data/lib/localeapp/cli/command.rb +34 -0
- data/lib/localeapp/cli/daemon.rb +54 -0
- data/lib/localeapp/cli/install.rb +16 -15
- data/lib/localeapp/cli/pull.rb +1 -5
- data/lib/localeapp/cli/push.rb +1 -5
- data/lib/localeapp/cli/update.rb +1 -5
- data/lib/localeapp/configuration.rb +23 -63
- data/lib/localeapp/default_value_handler.rb +1 -9
- data/lib/localeapp/version.rb +1 -1
- data/lib/localeapp.rb +12 -15
- data/spec/localeapp/cli/add_spec.rb +1 -1
- data/spec/localeapp/cli/daemon_spec.rb +38 -0
- data/spec/localeapp/cli/install_spec.rb +10 -10
- data/spec/localeapp/cli/pull_spec.rb +2 -2
- data/spec/localeapp/cli/push_spec.rb +2 -2
- data/spec/localeapp/cli/update_spec.rb +1 -1
- data/spec/localeapp/configuration_spec.rb +39 -186
- data/spec/localeapp/default_value_handler_spec.rb +4 -13
- data/spec/localeapp/sender_spec.rb +0 -21
- metadata +57 -41
- data/features/localeapp_binary.feature +0 -210
@@ -44,33 +44,6 @@ module Localeapp
|
|
44
44
|
# (defaults to 'development')
|
45
45
|
attr_accessor :polling_environments
|
46
46
|
|
47
|
-
# @deprecated Use {#sending_environments} instead. This is safer but make sure to reverse your logic if you've changed the defaults
|
48
|
-
# The names of environments where notifications aren't sent (defaults to
|
49
|
-
# 'test', 'cucumber', 'production')
|
50
|
-
attr_accessor :disabled_sending_environments
|
51
|
-
def disabled_sending_environments=(value)
|
52
|
-
@deprecated_environment_config_used = true
|
53
|
-
@disabled_sending_environments = value
|
54
|
-
end
|
55
|
-
|
56
|
-
# @deprecated Use {#reloading_environments} instead. This is safer but make sure to reverse your logic if you've changed the defaults
|
57
|
-
# The names of environments where I18n.reload isn't called for each request
|
58
|
-
# (defaults to 'test', 'cucumber', 'production')
|
59
|
-
attr_accessor :disabled_reloading_environments
|
60
|
-
def disabled_reloading_environments=(value)
|
61
|
-
@deprecated_environment_config_used = true
|
62
|
-
@disabled_reloading_environments = value
|
63
|
-
end
|
64
|
-
|
65
|
-
# @deprecated Use {#polling_environments} instead. This is safer but make sure to reverse your logic if you've changed the defaults
|
66
|
-
# The names of environments where updates aren't pulled (defaults to
|
67
|
-
# 'test', 'cucumber', 'production')
|
68
|
-
attr_accessor :disabled_polling_environments
|
69
|
-
def disabled_polling_environments=(value)
|
70
|
-
@deprecated_environment_config_used = true
|
71
|
-
@disabled_polling_environments = value
|
72
|
-
end
|
73
|
-
|
74
47
|
# The logger used by Localeapp
|
75
48
|
attr_accessor :logger
|
76
49
|
|
@@ -94,56 +67,43 @@ module Localeapp
|
|
94
67
|
# The complete path to the directory where translations are stored
|
95
68
|
attr_accessor :translation_data_directory
|
96
69
|
|
97
|
-
def
|
98
|
-
|
70
|
+
def initialize
|
71
|
+
defaults.each do |setting, value|
|
72
|
+
send("#{setting}=", value)
|
73
|
+
end
|
99
74
|
end
|
100
75
|
|
101
|
-
def
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
@translation_data_directory = File.join('config', 'locales')
|
76
|
+
def defaults
|
77
|
+
defaults = {
|
78
|
+
:host => 'api.localeapp.com',
|
79
|
+
:secure => true,
|
80
|
+
:ssl_verify => false,
|
81
|
+
:sending_environments => %w(development),
|
82
|
+
:reloading_environments => %w(development),
|
83
|
+
:polling_environments => %w(development),
|
84
|
+
:poll_interval => 0,
|
85
|
+
:synchronization_data_file => File.join('log', 'localeapp.yml'),
|
86
|
+
:daemon_pid_file => File.join('tmp', 'pids', 'localeapp.pid'),
|
87
|
+
:daemon_log_file => File.join('log', 'localeapp_daemon.log'),
|
88
|
+
:translation_data_directory => File.join('config', 'locales'),
|
89
|
+
}
|
116
90
|
if ENV['DEBUG']
|
117
91
|
require 'logger'
|
118
|
-
|
92
|
+
defaults[:logger] = Logger.new(STDOUT)
|
119
93
|
end
|
94
|
+
defaults
|
120
95
|
end
|
121
96
|
|
122
97
|
def polling_disabled?
|
123
|
-
|
124
|
-
::Localeapp.log "DEPRECATION: disabled_polling_environments is deprecated and will be removed. Use polling_environments instead and reverse the logic if you've changed the defaults"
|
125
|
-
disabled_polling_environments.map { |v| v.to_s }.include?(environment_name)
|
126
|
-
else
|
127
|
-
!polling_environments.map { |v| v.to_s }.include?(environment_name)
|
128
|
-
end
|
98
|
+
!polling_environments.map { |v| v.to_s }.include?(environment_name)
|
129
99
|
end
|
130
100
|
|
131
101
|
def reloading_disabled?
|
132
|
-
|
133
|
-
::Localeapp.log "DEPRECATION: disabled_reloading_environments is deprecated and will be removed. Use reloading_environments instead and reverse the logic if you've changed the defaults"
|
134
|
-
disabled_reloading_environments.map { |v| v.to_s }.include?(environment_name)
|
135
|
-
else
|
136
|
-
!reloading_environments.map { |v| v.to_s }.include?(environment_name)
|
137
|
-
end
|
102
|
+
!reloading_environments.map { |v| v.to_s }.include?(environment_name)
|
138
103
|
end
|
139
104
|
|
140
105
|
def sending_disabled?
|
141
|
-
|
142
|
-
::Localeapp.log "DEPRECATION: disabled_sending_environments is deprecated and will be removed. Use sending_environments instead and reverse the logic if you've changed the defaults"
|
143
|
-
disabled_sending_environments.map { |v| v.to_s }.include?(environment_name)
|
144
|
-
else
|
145
|
-
!sending_environments.map { |v| v.to_s }.include?(environment_name)
|
146
|
-
end
|
106
|
+
!sending_environments.map { |v| v.to_s }.include?(environment_name)
|
147
107
|
end
|
148
108
|
|
149
109
|
def write_rails_configuration(path)
|
@@ -3,15 +3,7 @@ module I18n::Backend::Base
|
|
3
3
|
|
4
4
|
def default(locale, object, subject, options = {})
|
5
5
|
result = default_without_handler(locale, object, subject, options)
|
6
|
-
|
7
|
-
|
8
|
-
if result
|
9
|
-
sender = Localeapp::Sender.new
|
10
|
-
|
11
|
-
# Make the default value a complete translation
|
12
|
-
sender.post_translation(locale, object, options, result)
|
13
|
-
end
|
14
|
-
|
6
|
+
Localeapp.missing_translations.add(locale, object, subject, options)
|
15
7
|
return result
|
16
8
|
end
|
17
9
|
end
|
data/lib/localeapp/version.rb
CHANGED
data/lib/localeapp.rb
CHANGED
@@ -35,11 +35,13 @@ require 'localeapp/key_checker'
|
|
35
35
|
require 'localeapp/missing_translations'
|
36
36
|
require 'localeapp/default_value_handler'
|
37
37
|
|
38
|
+
require 'localeapp/cli/command'
|
38
39
|
require 'localeapp/cli/install'
|
39
40
|
require 'localeapp/cli/pull'
|
40
41
|
require 'localeapp/cli/push'
|
41
42
|
require 'localeapp/cli/update'
|
42
43
|
require 'localeapp/cli/add'
|
44
|
+
require 'localeapp/cli/daemon'
|
43
45
|
|
44
46
|
# AUDIT: Will this work on ruby 1.9.x
|
45
47
|
$KCODE="UTF8" if RUBY_VERSION < '1.9'
|
@@ -88,27 +90,22 @@ module Localeapp
|
|
88
90
|
# end
|
89
91
|
def configure
|
90
92
|
self.configuration ||= Configuration.new
|
91
|
-
yield(configuration)
|
93
|
+
yield(configuration) if block_given?
|
92
94
|
self.sender = Sender.new
|
93
95
|
self.poller = Poller.new
|
94
96
|
self.updater = Updater.new
|
95
97
|
@missing_translations = MissingTranslations.new
|
96
98
|
end
|
97
99
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
return true
|
108
|
-
rescue
|
109
|
-
end
|
110
|
-
end
|
111
|
-
false
|
100
|
+
def has_config_file?
|
101
|
+
default_config_file_paths.any? { |path| File.exists?(path) }
|
102
|
+
end
|
103
|
+
|
104
|
+
def default_config_file_paths
|
105
|
+
[
|
106
|
+
File.join(Dir.pwd, '.localeapp', 'config.rb'),
|
107
|
+
File.join(Dir.pwd, 'config', 'initializers', 'localeapp.rb')
|
108
|
+
]
|
112
109
|
end
|
113
110
|
|
114
111
|
def load_yaml(contents)
|
@@ -8,7 +8,7 @@ describe Localeapp::CLI::Add, "#execute(key, *translations)" do
|
|
8
8
|
|
9
9
|
before(:each) do
|
10
10
|
@output = StringIO.new
|
11
|
-
@command = Localeapp::CLI::Add.new(@output)
|
11
|
+
@command = Localeapp::CLI::Add.new(:output => @output)
|
12
12
|
end
|
13
13
|
|
14
14
|
it "adds the translations to missing_translations" do
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Localeapp::CLI::Daemon, "#execute(options)" do
|
4
|
+
let(:output) { StringIO.new }
|
5
|
+
let(:command) { Localeapp::CLI::Daemon.new(:output => output) }
|
6
|
+
let(:interval) { 5 }
|
7
|
+
|
8
|
+
before do
|
9
|
+
command.stub(:update_loop)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "exits when interval isn't greater than 0" do
|
13
|
+
command.should_receive(:exit_now!)
|
14
|
+
command.execute(:interval => -1)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "runs the loop directly when not running in background" do
|
18
|
+
command.should_receive(:update_loop).with(interval)
|
19
|
+
command.execute(:interval => interval)
|
20
|
+
end
|
21
|
+
|
22
|
+
it "runs the loop in the background when background options set" do
|
23
|
+
command.should_receive(:run_in_background).with(interval)
|
24
|
+
command.execute(:interval => interval, :background => true)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe Localeapp::CLI::Daemon, "#do_update" do
|
29
|
+
let(:output) { StringIO.new }
|
30
|
+
let(:command) { Localeapp::CLI::Daemon.new(:output => output) }
|
31
|
+
|
32
|
+
it "creates and executes and Updater" do
|
33
|
+
stub = stub(:updater)
|
34
|
+
stub.should_receive(:execute)
|
35
|
+
Localeapp::CLI::Update.should_receive(:new).and_return(stub)
|
36
|
+
command.do_update
|
37
|
+
end
|
38
|
+
end
|
@@ -4,24 +4,24 @@ require 'localeapp/cli/install'
|
|
4
4
|
describe Localeapp::CLI::Install, '.execute(key, output = $stdout)' do
|
5
5
|
before(:each) do
|
6
6
|
@output = StringIO.new
|
7
|
-
@command = Localeapp::CLI::Install.new
|
7
|
+
@command = Localeapp::CLI::Install.new(:output => @output)
|
8
8
|
end
|
9
9
|
|
10
10
|
it "displays error if key is nil" do
|
11
|
-
@command.execute(nil
|
11
|
+
@command.execute(nil)
|
12
12
|
@output.string.should match(/You must supply an API key/)
|
13
13
|
end
|
14
14
|
|
15
15
|
it "displays error if the key is there but isn't valid on localeapp.com" do
|
16
16
|
@command.stub!(:check_key).and_return([false, {}])
|
17
|
-
@command.execute('API_KEY'
|
17
|
+
@command.execute('API_KEY')
|
18
18
|
@output.string.should match(/Project not found/)
|
19
19
|
end
|
20
20
|
|
21
21
|
it "displays project name and base locale if the key is there and valid on localeapp.com" do
|
22
22
|
@command.stub!(:check_key).and_return([true, valid_project_data])
|
23
23
|
@command.stub!(:write_configuration_file)
|
24
|
-
@command.execute('API_KEY'
|
24
|
+
@command.execute('API_KEY')
|
25
25
|
@output.string.should match(/Test Project/)
|
26
26
|
@output.string.should match(/en \(English\)/)
|
27
27
|
end
|
@@ -30,27 +30,27 @@ describe Localeapp::CLI::Install, '.execute(key, output = $stdout)' do
|
|
30
30
|
I18n.stub(:default_locale).and_return(:es)
|
31
31
|
@command.stub!(:check_key).and_return([true, valid_project_data])
|
32
32
|
@command.stub!(:write_configuration_file)
|
33
|
-
@command.execute('API_KEY'
|
33
|
+
@command.execute('API_KEY')
|
34
34
|
@output.string.should match(%r{WARNING: I18n.default_locale is es, change in config/environment.rb \(Rails 2\) or config/application.rb \(Rails 3\)})
|
35
35
|
end
|
36
36
|
|
37
37
|
it "asks the default configuration to write itself" do
|
38
38
|
@command.stub!(:check_key).and_return([true, valid_project_data])
|
39
39
|
@command.should_receive(:write_configuration_file).with('config/initializers/localeapp.rb')
|
40
|
-
@command.execute('API_KEY'
|
40
|
+
@command.execute('API_KEY')
|
41
41
|
end
|
42
42
|
|
43
43
|
it "asks the configuration to write itself to .localeapp when the --standalone switch is set" do
|
44
44
|
@command.stub!(:check_key).and_return([true, valid_project_data])
|
45
45
|
@command.config_type = :standalone
|
46
46
|
@command.should_receive(:write_configuration_file).with('.localeapp/config.rb')
|
47
|
-
@command.execute('API_KEY'
|
47
|
+
@command.execute('API_KEY')
|
48
48
|
end
|
49
49
|
|
50
50
|
it "displays warning if config.translation_data_directory doesn't exist" do
|
51
51
|
@command.stub!(:check_key).and_return([true, valid_project_data])
|
52
52
|
@command.stub!(:write_configuration_file)
|
53
|
-
@command.execute('API_KEY'
|
53
|
+
@command.execute('API_KEY')
|
54
54
|
@output.string.should match(/Your translation data will be stored there./)
|
55
55
|
end
|
56
56
|
|
@@ -58,7 +58,7 @@ describe Localeapp::CLI::Install, '.execute(key, output = $stdout)' do
|
|
58
58
|
@command.stub!(:check_key).and_return([true, valid_project_data])
|
59
59
|
@command.stub!(:write_configuration_file)
|
60
60
|
File.should_receive(:directory?).and_return(true)
|
61
|
-
@command.execute('API_KEY'
|
61
|
+
@command.execute('API_KEY')
|
62
62
|
@output.string.should_not match(/Your translation data will be stored there./)
|
63
63
|
end
|
64
64
|
|
@@ -66,6 +66,6 @@ describe Localeapp::CLI::Install, '.execute(key, output = $stdout)' do
|
|
66
66
|
@command.stub!(:check_key).and_return([true, valid_project_data])
|
67
67
|
@command.config_type = :github
|
68
68
|
@command.should_receive(:write_github_configuration_file).with('.localeapp/config.rb', valid_project_data)
|
69
|
-
@command.execute('API_KEY'
|
69
|
+
@command.execute('API_KEY')
|
70
70
|
end
|
71
71
|
end
|
@@ -4,7 +4,7 @@ require 'localeapp/cli/pull'
|
|
4
4
|
describe Localeapp::CLI::Pull, "#execute" do
|
5
5
|
before do
|
6
6
|
@output = StringIO.new
|
7
|
-
@puller = Localeapp::CLI::Pull.new(@output)
|
7
|
+
@puller = Localeapp::CLI::Pull.new(:output => @output)
|
8
8
|
end
|
9
9
|
|
10
10
|
it "makes the api call to the translations endpoint" do
|
@@ -24,7 +24,7 @@ describe Localeapp::CLI::Pull, "#update_backend(response)" do
|
|
24
24
|
before do
|
25
25
|
@test_data = ['test data'].to_json
|
26
26
|
@output = StringIO.new
|
27
|
-
@puller = Localeapp::CLI::Pull.new(@output)
|
27
|
+
@puller = Localeapp::CLI::Pull.new(:output => @output)
|
28
28
|
end
|
29
29
|
|
30
30
|
it "calls the updater" do
|
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Localeapp::CLI::Push, "#execute(path)" do
|
4
4
|
let(:output) { StringIO.new }
|
5
|
-
let(:pusher) { Localeapp::CLI::Push.new(output) }
|
5
|
+
let(:pusher) { Localeapp::CLI::Push.new(:output => output) }
|
6
6
|
|
7
7
|
context "path is a directory" do
|
8
8
|
it "calls push_file on each yaml file in the directory" do
|
@@ -33,7 +33,7 @@ end
|
|
33
33
|
|
34
34
|
describe Localeapp::CLI::Push, "#push_file(file_path)" do
|
35
35
|
let(:output) { StringIO.new }
|
36
|
-
let(:pusher) { Localeapp::CLI::Push.new(output) }
|
36
|
+
let(:pusher) { Localeapp::CLI::Push.new(:output => output) }
|
37
37
|
|
38
38
|
it "creates a new file object and makes the api call to the translations endpoint" do
|
39
39
|
with_configuration do
|
@@ -4,7 +4,7 @@ require 'localeapp/cli/update'
|
|
4
4
|
describe Localeapp::CLI::Update, "#execute" do
|
5
5
|
before do
|
6
6
|
@output = StringIO.new
|
7
|
-
@updater = Localeapp::CLI::Update.new(@output)
|
7
|
+
@updater = Localeapp::CLI::Update.new(:output => @output)
|
8
8
|
end
|
9
9
|
|
10
10
|
it "creates a Poller and calls poll! on it" do
|
@@ -95,210 +95,63 @@ describe Localeapp::Configuration do
|
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
98
|
-
|
99
|
-
it "
|
100
|
-
configuration.
|
101
|
-
configuration.
|
102
|
-
|
103
|
-
|
104
|
-
it "does not include development by default" do
|
105
|
-
configuration.environment_name = 'development'
|
106
|
-
configuration.sending_disabled?.should be_false
|
107
|
-
end
|
108
|
-
|
109
|
-
it "include cucumber by default" do
|
110
|
-
configuration.environment_name = 'cucumber'
|
111
|
-
configuration.sending_disabled?.should be_true
|
112
|
-
end
|
113
|
-
|
114
|
-
it "include test by default" do
|
115
|
-
configuration.environment_name = 'test'
|
116
|
-
configuration.sending_disabled?.should be_true
|
117
|
-
end
|
118
|
-
|
119
|
-
it "include production by default" do
|
120
|
-
configuration.environment_name = 'production'
|
121
|
-
configuration.sending_disabled?.should be_true
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
context "disabled_reloading_environments" do
|
126
|
-
it "sets deprecated_environment_config_used flag to true" do
|
127
|
-
configuration.disabled_reloading_environments = %w(foo bar)
|
128
|
-
configuration.deprecated_environment_config_used?.should be_true
|
129
|
-
end
|
130
|
-
|
131
|
-
it "does not include development by default" do
|
132
|
-
configuration.environment_name = 'development'
|
133
|
-
configuration.reloading_disabled?.should be_false
|
134
|
-
end
|
135
|
-
|
136
|
-
it "include cucumber by default" do
|
137
|
-
configuration.environment_name = 'cucumber'
|
138
|
-
configuration.reloading_disabled?.should be_true
|
98
|
+
describe "polling_disabled?" do
|
99
|
+
it "is true when environment is not enabled" do
|
100
|
+
configuration.polling_environments = %w(foo)
|
101
|
+
configuration.environment_name = 'bar'
|
102
|
+
configuration.should be_polling_disabled
|
139
103
|
end
|
140
104
|
|
141
|
-
it "
|
142
|
-
configuration.
|
143
|
-
configuration.
|
105
|
+
it "is false when environment is enabled" do
|
106
|
+
configuration.polling_environments = %w(foo)
|
107
|
+
configuration.environment_name = 'foo'
|
108
|
+
configuration.should_not be_polling_disabled
|
144
109
|
end
|
145
110
|
|
146
|
-
it "
|
147
|
-
configuration.
|
148
|
-
configuration.
|
111
|
+
it "supports symbols in list of environments" do
|
112
|
+
configuration.polling_environments = [:foo]
|
113
|
+
configuration.environment_name = 'foo'
|
114
|
+
configuration.should_not be_polling_disabled
|
149
115
|
end
|
150
116
|
end
|
151
|
-
|
152
|
-
context "disabled_polling_environments" do
|
153
|
-
it "sets deprecated_environment_config_used flag to true" do
|
154
|
-
configuration.disabled_polling_environments = %w(foo bar)
|
155
|
-
configuration.deprecated_environment_config_used?.should be_true
|
156
|
-
end
|
157
|
-
|
158
|
-
it "does not include development by default" do
|
159
|
-
configuration.environment_name = 'development'
|
160
|
-
configuration.polling_disabled?.should be_false
|
161
|
-
end
|
162
|
-
|
163
|
-
it "include cucumber by default" do
|
164
|
-
configuration.environment_name = 'cucumber'
|
165
|
-
configuration.polling_disabled?.should be_true
|
166
|
-
end
|
167
|
-
|
168
|
-
it "include test by default" do
|
169
|
-
configuration.environment_name = 'test'
|
170
|
-
configuration.polling_disabled?.should be_true
|
171
|
-
end
|
172
117
|
|
173
|
-
|
174
|
-
|
175
|
-
configuration.
|
118
|
+
describe "reloading_disabled?" do
|
119
|
+
it "is true when environment is not enabled" do
|
120
|
+
configuration.reloading_environments = %w(foo)
|
121
|
+
configuration.environment_name = 'bar'
|
122
|
+
configuration.should be_reloading_disabled
|
176
123
|
end
|
177
|
-
end
|
178
124
|
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
configuration.environment_name = 'foo'
|
184
|
-
configuration.should be_polling_disabled
|
185
|
-
end
|
186
|
-
|
187
|
-
it "is false when environment is not disabled" do
|
188
|
-
configuration.disabled_polling_environments = %w(foo)
|
189
|
-
configuration.environment_name = 'bar'
|
190
|
-
configuration.should_not be_polling_disabled
|
191
|
-
end
|
192
|
-
|
193
|
-
it "supports symbols in list of environments" do
|
194
|
-
configuration.disabled_polling_environments = [:foo]
|
195
|
-
configuration.environment_name = 'foo'
|
196
|
-
configuration.should be_polling_disabled
|
197
|
-
end
|
125
|
+
it "is false when environment is enabled" do
|
126
|
+
configuration.reloading_environments = %w(foo)
|
127
|
+
configuration.environment_name = 'foo'
|
128
|
+
configuration.should_not be_reloading_disabled
|
198
129
|
end
|
199
130
|
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
configuration.should be_polling_disabled
|
205
|
-
end
|
206
|
-
|
207
|
-
it "is false when environment is enabled" do
|
208
|
-
configuration.polling_environments = %w(foo)
|
209
|
-
configuration.environment_name = 'foo'
|
210
|
-
configuration.should_not be_polling_disabled
|
211
|
-
end
|
212
|
-
|
213
|
-
it "supports symbols in list of environments" do
|
214
|
-
configuration.polling_environments = [:foo]
|
215
|
-
configuration.environment_name = 'foo'
|
216
|
-
configuration.should_not be_polling_disabled
|
217
|
-
end
|
131
|
+
it "supports symbols in list of environments" do
|
132
|
+
configuration.reloading_environments = [:foo]
|
133
|
+
configuration.environment_name = 'foo'
|
134
|
+
configuration.should_not be_reloading_disabled
|
218
135
|
end
|
219
136
|
end
|
220
137
|
|
221
|
-
describe "
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
configuration.should be_reloading_disabled
|
227
|
-
end
|
228
|
-
|
229
|
-
it "is false when environment is not disabled" do
|
230
|
-
configuration.disabled_reloading_environments = %w(foo)
|
231
|
-
configuration.environment_name = 'bar'
|
232
|
-
configuration.should_not be_reloading_disabled
|
233
|
-
end
|
234
|
-
|
235
|
-
it "supports symbols in list of environments" do
|
236
|
-
configuration.disabled_reloading_environments = [:foo]
|
237
|
-
configuration.environment_name = 'foo'
|
238
|
-
configuration.should be_reloading_disabled
|
239
|
-
end
|
240
|
-
end
|
241
|
-
|
242
|
-
context "new syntax used" do
|
243
|
-
it "is true when environment is not enabled" do
|
244
|
-
configuration.reloading_environments = %w(foo)
|
245
|
-
configuration.environment_name = 'bar'
|
246
|
-
configuration.should be_reloading_disabled
|
247
|
-
end
|
248
|
-
|
249
|
-
it "is false when environment is enabled" do
|
250
|
-
configuration.reloading_environments = %w(foo)
|
251
|
-
configuration.environment_name = 'foo'
|
252
|
-
configuration.should_not be_reloading_disabled
|
253
|
-
end
|
254
|
-
|
255
|
-
it "supports symbols in list of environments" do
|
256
|
-
configuration.reloading_environments = [:foo]
|
257
|
-
configuration.environment_name = 'foo'
|
258
|
-
configuration.should_not be_reloading_disabled
|
259
|
-
end
|
138
|
+
describe "sending_disabled?" do
|
139
|
+
it "is true when environment is not enabled" do
|
140
|
+
configuration.sending_environments = %w(foo)
|
141
|
+
configuration.environment_name = 'bar'
|
142
|
+
configuration.should be_sending_disabled
|
260
143
|
end
|
261
|
-
end
|
262
144
|
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
configuration.environment_name = 'foo'
|
268
|
-
configuration.should be_sending_disabled
|
269
|
-
end
|
270
|
-
|
271
|
-
it "is false when environment is not disabled" do
|
272
|
-
configuration.disabled_sending_environments = %w(foo)
|
273
|
-
configuration.environment_name = 'bar'
|
274
|
-
configuration.should_not be_sending_disabled
|
275
|
-
end
|
276
|
-
|
277
|
-
it "supports symbols in the list of enviroments" do
|
278
|
-
configuration.disabled_sending_environments = [:foo]
|
279
|
-
configuration.environment_name = 'foo'
|
280
|
-
configuration.should be_sending_disabled
|
281
|
-
end
|
145
|
+
it "is false when environment is enabled" do
|
146
|
+
configuration.sending_environments = %w(foo)
|
147
|
+
configuration.environment_name = 'foo'
|
148
|
+
configuration.should_not be_sending_disabled
|
282
149
|
end
|
283
150
|
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
configuration.should be_sending_disabled
|
289
|
-
end
|
290
|
-
|
291
|
-
it "is false when environment is enabled" do
|
292
|
-
configuration.sending_environments = %w(foo)
|
293
|
-
configuration.environment_name = 'foo'
|
294
|
-
configuration.should_not be_sending_disabled
|
295
|
-
end
|
296
|
-
|
297
|
-
it "supports symbols in the list of environments" do
|
298
|
-
configuration.sending_environments = [:foo]
|
299
|
-
configuration.environment_name = 'foo'
|
300
|
-
configuration.should_not be_sending_disabled
|
301
|
-
end
|
151
|
+
it "supports symbols in the list of environments" do
|
152
|
+
configuration.sending_environments = [:foo]
|
153
|
+
configuration.environment_name = 'foo'
|
154
|
+
configuration.should_not be_sending_disabled
|
302
155
|
end
|
303
156
|
end
|
304
157
|
end
|
@@ -7,19 +7,10 @@ end
|
|
7
7
|
describe I18n::Backend::Base, '#default' do
|
8
8
|
let(:klass) { Klass.new }
|
9
9
|
|
10
|
-
it "
|
10
|
+
it "adds translations to missing translations to send to Locale" do
|
11
11
|
with_configuration(:sending_environments => ['my_env'], :environment_name => 'my_env' ) do
|
12
|
-
|
13
|
-
|
14
|
-
sender.should_receive(:post_translation)
|
15
|
-
klass.default('locale', 'object', 'subject')
|
12
|
+
Localeapp.missing_translations.should_receive(:add).with(:en, 'foo', 'bar', :baz => 'bam')
|
13
|
+
klass.default(:en, 'foo', 'bar', :baz => 'bam')
|
16
14
|
end
|
17
15
|
end
|
18
|
-
|
19
|
-
it "doesn't post when sending is disabled" do
|
20
|
-
with_configuration(:sending_environments => []) do
|
21
|
-
Localeapp::Sender.should_not_receive(:new)
|
22
|
-
klass.default('locale', 'object', 'subject')
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
16
|
+
end
|