localeapp 0.9.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/.travis.yml +5 -1
- data/CHANGELOG.md +10 -0
- data/README.md +2 -2
- data/bin/localeapp +6 -4
- data/features/add.feature +11 -12
- data/features/install.feature +28 -28
- data/features/mv.feature +2 -2
- data/features/pull.feature +8 -8
- data/features/push.feature +12 -12
- data/features/rm.feature +2 -2
- data/features/step_definitions/cli_steps.rb +2 -6
- data/features/support/env.rb +3 -5
- data/features/support/hooks.rb +3 -3
- data/features/update.feature +19 -19
- data/lib/localeapp/version.rb +1 -1
- data/localeapp.gemspec +4 -4
- data/spec/localeapp/api_call_spec.rb +2 -2
- data/spec/localeapp/api_caller_spec.rb +45 -43
- data/spec/localeapp/cli/add_spec.rb +14 -14
- data/spec/localeapp/cli/daemon_spec.rb +6 -6
- data/spec/localeapp/cli/install_spec.rb +53 -53
- data/spec/localeapp/cli/pull_spec.rb +5 -5
- data/spec/localeapp/cli/push_spec.rb +9 -9
- data/spec/localeapp/cli/rename_spec.rb +1 -1
- data/spec/localeapp/cli/update_spec.rb +9 -6
- data/spec/localeapp/configuration_spec.rb +29 -29
- data/spec/localeapp/default_value_handler_spec.rb +8 -8
- data/spec/localeapp/exception_handler_spec.rb +6 -6
- data/spec/localeapp/key_checker_spec.rb +2 -2
- data/spec/localeapp/missing_translations_spec.rb +18 -18
- data/spec/localeapp/poller_spec.rb +12 -12
- data/spec/localeapp/rails/controller_spec.rb +13 -13
- data/spec/localeapp/routes_spec.rb +34 -34
- data/spec/localeapp/sender_spec.rb +5 -5
- data/spec/localeapp/updater_spec.rb +14 -14
- metadata +15 -15
@@ -20,21 +20,21 @@ describe I18n::Backend::Base, '#default' do
|
|
20
20
|
describe "when subject is a String" do
|
21
21
|
it "adds translations to missing translations to send to Locale" do
|
22
22
|
allow_sending do
|
23
|
-
Localeapp.missing_translations.
|
23
|
+
expect(Localeapp.missing_translations).to receive(:add).with(:en, 'foo', 'bar', :baz => 'bam')
|
24
24
|
klass.default(:en, 'foo', 'bar', :baz => 'bam')
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
28
|
it "strips the subject when the translation is not in the default locale" do
|
29
29
|
allow_sending do
|
30
|
-
Localeapp.missing_translations.
|
30
|
+
expect(Localeapp.missing_translations).to receive(:add).with(:fr, 'foo', nil, :baz => 'bam')
|
31
31
|
klass.default(:fr, 'foo', 'bar', :baz => 'bam')
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
35
|
it "adds translations to missing translations when using a string as the locale" do
|
36
36
|
allow_sending do
|
37
|
-
Localeapp.missing_translations.
|
37
|
+
expect(Localeapp.missing_translations).to receive(:add).with('en', 'foo', 'bar', :baz => 'bam')
|
38
38
|
klass.default('en', 'foo', 'bar', :baz => 'bam')
|
39
39
|
end
|
40
40
|
end
|
@@ -45,7 +45,7 @@ describe I18n::Backend::Base, '#default' do
|
|
45
45
|
describe "and there is a text inside the array" do
|
46
46
|
it "add translations to missing translations to send to Locale" do
|
47
47
|
allow_sending do
|
48
|
-
Localeapp.missing_translations.
|
48
|
+
expect(Localeapp.missing_translations).to receive(:add).with(:en, 'foo', 'correct default', :baz => 'bam')
|
49
49
|
klass.default(:en, 'foo', [:missing, 'correct default'], :baz => 'bam')
|
50
50
|
end
|
51
51
|
end
|
@@ -54,8 +54,8 @@ describe I18n::Backend::Base, '#default' do
|
|
54
54
|
describe "and there is not a text inside the array" do
|
55
55
|
it "doesn't send anything to Locale" do
|
56
56
|
allow_sending do
|
57
|
-
Localeapp.missing_translations.
|
58
|
-
I18n.
|
57
|
+
expect(Localeapp.missing_translations).not_to receive(:add)
|
58
|
+
allow(I18n).to receive(:translate) do |subject, _|
|
59
59
|
subject == :not_missing ? "not missing" : nil
|
60
60
|
end
|
61
61
|
klass.default(:en, 'foo', [:missing, :not_missing], :baz => 'bam')
|
@@ -67,7 +67,7 @@ describe I18n::Backend::Base, '#default' do
|
|
67
67
|
describe "when subject is a Symbol" do
|
68
68
|
it "doesn't send anything to Locale" do
|
69
69
|
allow_sending do
|
70
|
-
Localeapp.missing_translations.
|
70
|
+
expect(Localeapp.missing_translations).not_to receive(:add)
|
71
71
|
klass.default(:en, 'foo', :other_key, :baz => 'bam')
|
72
72
|
end
|
73
73
|
end
|
@@ -77,7 +77,7 @@ describe I18n::Backend::Base, '#default' do
|
|
77
77
|
i18n = I18nWithFallbacks.new
|
78
78
|
|
79
79
|
with_configuration(:sending_environments => ['my_env'], :environment_name => 'my_env' ) do
|
80
|
-
Localeapp.missing_translations.
|
80
|
+
expect(Localeapp.missing_translations).to receive(:add).with(:en, 'my.object', 'my default', {:default => 'my default'})
|
81
81
|
i18n.translate(:en, 'my.object', :default => 'my default')
|
82
82
|
end
|
83
83
|
end
|
@@ -9,24 +9,24 @@ describe Localeapp::ExceptionHandler, '#call(exception, locale, key, options)' d
|
|
9
9
|
end
|
10
10
|
|
11
11
|
it "adds the missing translation to the missing translation list" do
|
12
|
-
Localeapp.missing_translations.
|
12
|
+
expect(Localeapp.missing_translations).to receive(:add).with(:en, 'foo', nil, { :baz => 'bam' })
|
13
13
|
I18n.t('foo', :baz => 'bam')
|
14
14
|
end
|
15
15
|
|
16
16
|
it "handles when the key is an array of keys" do
|
17
|
-
Localeapp.missing_translations.
|
18
|
-
Localeapp.missing_translations.
|
17
|
+
expect(Localeapp.missing_translations).to receive(:add).with(:en, 'foo', nil, {})
|
18
|
+
expect(Localeapp.missing_translations).to receive(:add).with(:en, 'bar', nil, {})
|
19
19
|
I18n.t(['foo', 'bar'])
|
20
20
|
end
|
21
21
|
|
22
22
|
it "handles when the default is a Symbol that can be resolved" do
|
23
23
|
I18n.backend.store_translations(:en, {:default_symbol_test => 'is resolved'})
|
24
|
-
Localeapp.missing_translations.
|
25
|
-
I18n.t(:foo, :default => :default_symbol_test).
|
24
|
+
expect(Localeapp.missing_translations).not_to receive(:add)
|
25
|
+
expect(I18n.t(:foo, :default => :default_symbol_test)).to eq('is resolved')
|
26
26
|
end
|
27
27
|
|
28
28
|
it "handles when the default is a Symbol that can't be resolved" do
|
29
|
-
Localeapp.missing_translations.
|
29
|
+
expect(Localeapp.missing_translations).to receive(:add).with(:en, :foo, nil, {:default => :bar})
|
30
30
|
I18n.t(:foo, :default => :bar)
|
31
31
|
end
|
32
32
|
|
@@ -6,7 +6,7 @@ describe Localeapp::KeyChecker, "#check(key)" do
|
|
6
6
|
with_configuration do
|
7
7
|
@checker = Localeapp::KeyChecker.new
|
8
8
|
end
|
9
|
-
@checker.check('TEST_KEY').
|
9
|
+
expect(@checker.check('TEST_KEY')).to eq([false, {}])
|
10
10
|
end
|
11
11
|
|
12
12
|
it "returns true and and the parsed json hash if the response from locale app is a 200" do
|
@@ -14,6 +14,6 @@ describe Localeapp::KeyChecker, "#check(key)" do
|
|
14
14
|
with_configuration do
|
15
15
|
@checker = Localeapp::KeyChecker.new
|
16
16
|
end
|
17
|
-
@checker.check('TEST_KEY').
|
17
|
+
expect(@checker.check('TEST_KEY')).to eq([true, valid_project_data])
|
18
18
|
end
|
19
19
|
end
|
@@ -5,17 +5,17 @@ describe Localeapp::MissingTranslations, "#add(locale, key, description = nil, o
|
|
5
5
|
it "stores the missing translation data" do
|
6
6
|
translations = Localeapp::MissingTranslations.new
|
7
7
|
translations.add(:en, 'foo', 'bar', { :baz => 'bam' })
|
8
|
-
translations[:en].
|
9
|
-
translations[:en]['foo'].description.
|
10
|
-
translations[:en]['foo'].options.
|
8
|
+
expect(translations[:en]).to include('foo')
|
9
|
+
expect(translations[:en]['foo'].description).to eq('bar')
|
10
|
+
expect(translations[:en]['foo'].options).to eq({ :baz => 'bam' })
|
11
11
|
end
|
12
12
|
|
13
13
|
it "respects I18n options when constructing a key" do
|
14
14
|
translations = Localeapp::MissingTranslations.new
|
15
15
|
translations.add(:en, 'foo', nil, { :scope => 'bar', :baz => 'bam' })
|
16
16
|
|
17
|
-
translations[:en].
|
18
|
-
translations[:en]['bar.foo'].options.
|
17
|
+
expect(translations[:en]).to include('bar.foo')
|
18
|
+
expect(translations[:en]['bar.foo'].options).to eq({ :baz => 'bam' })
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
@@ -26,26 +26,26 @@ describe Localeapp::MissingTranslations, "#to_send" do
|
|
26
26
|
translations.add(:es, 'bar', 'baz')
|
27
27
|
|
28
28
|
to_send = translations.to_send
|
29
|
-
to_send.size.
|
30
|
-
to_send[0][:key].
|
31
|
-
to_send[0][:locale].
|
32
|
-
to_send[0].
|
33
|
-
to_send[0][:options].
|
34
|
-
to_send[1][:key].
|
35
|
-
to_send[1][:locale].
|
36
|
-
to_send[1][:description].
|
37
|
-
to_send[1][:options].
|
29
|
+
expect(to_send.size).to eq(2)
|
30
|
+
expect(to_send[0][:key]).to eq('foo')
|
31
|
+
expect(to_send[0][:locale]).to eq(:en)
|
32
|
+
expect(to_send[0]).not_to have_key(:description)
|
33
|
+
expect(to_send[0][:options]).to eq({ :baz => 'bam' })
|
34
|
+
expect(to_send[1][:key]).to eq('bar')
|
35
|
+
expect(to_send[1][:locale]).to eq(:es)
|
36
|
+
expect(to_send[1][:description]).to eq('baz')
|
37
|
+
expect(to_send[1][:options]).to eq({})
|
38
38
|
end
|
39
39
|
|
40
40
|
it "doesn't send the same key twice when cache_missing_translations is true" do
|
41
41
|
with_configuration(:cache_missing_translations => true) do
|
42
42
|
translation_a = Localeapp::MissingTranslations.new
|
43
43
|
translation_a.add(:es, 'foobybar')
|
44
|
-
translation_a.to_send.size.
|
44
|
+
expect(translation_a.to_send.size).to eq(1)
|
45
45
|
|
46
46
|
translation_b = Localeapp::MissingTranslations.new
|
47
47
|
translation_b.add(:en, 'foobybar')
|
48
|
-
translation_a.to_send.size.
|
48
|
+
expect(translation_a.to_send.size).to eq(0)
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
@@ -53,11 +53,11 @@ describe Localeapp::MissingTranslations, "#to_send" do
|
|
53
53
|
with_configuration(:cache_missing_translations => false) do
|
54
54
|
translation_a = Localeapp::MissingTranslations.new
|
55
55
|
translation_a.add(:es, 'foobybar')
|
56
|
-
translation_a.to_send.size.
|
56
|
+
expect(translation_a.to_send.size).to eq(1)
|
57
57
|
|
58
58
|
translation_b = Localeapp::MissingTranslations.new
|
59
59
|
translation_b.add(:en, 'foobybar')
|
60
|
-
translation_a.to_send.size.
|
60
|
+
expect(translation_a.to_send.size).to eq(1)
|
61
61
|
end
|
62
62
|
end
|
63
63
|
end
|
@@ -16,11 +16,11 @@ describe Localeapp::Poller do
|
|
16
16
|
describe "#needs_reloading?" do
|
17
17
|
it "returns true when updated_at has been changed in the synchronization file" do
|
18
18
|
@poller.write_synchronization_data!(@poller.polled_at, 12345)
|
19
|
-
@poller.needs_reloading
|
19
|
+
expect(@poller.needs_reloading?).to be true
|
20
20
|
end
|
21
21
|
|
22
22
|
it "returns false when updated_at is the same as in the synchronization file" do
|
23
|
-
@poller.needs_reloading
|
23
|
+
expect(@poller.needs_reloading?).to be false
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
@@ -49,17 +49,17 @@ describe Localeapp::Poller do
|
|
49
49
|
end
|
50
50
|
|
51
51
|
it "returns false" do
|
52
|
-
@poller.poll
|
52
|
+
expect(@poller.poll!).to eq(false)
|
53
53
|
end
|
54
54
|
|
55
55
|
it "updates the polled_at but not the updated_at synchronization data" do
|
56
|
-
@poller.
|
57
|
-
@poller.
|
56
|
+
allow(@poller).to receive(:current_time).and_return(polled_at_time)
|
57
|
+
expect(@poller).to receive(:write_synchronization_data!).with(polled_at_time, @updated_at)
|
58
58
|
@poller.poll!
|
59
59
|
end
|
60
60
|
|
61
61
|
it "updates the synchronization data" do
|
62
|
-
@poller.
|
62
|
+
expect(@poller).to receive(:write_synchronization_data!)
|
63
63
|
@poller.poll!
|
64
64
|
end
|
65
65
|
end
|
@@ -70,11 +70,11 @@ describe Localeapp::Poller do
|
|
70
70
|
end
|
71
71
|
|
72
72
|
it "returns false" do
|
73
|
-
@poller.poll
|
73
|
+
expect(@poller.poll!).to eq(false)
|
74
74
|
end
|
75
75
|
|
76
76
|
it "doesn't update the synchronization data" do
|
77
|
-
@poller.
|
77
|
+
expect(@poller).not_to receive(:write_synchronization_data!)
|
78
78
|
@poller.poll!
|
79
79
|
end
|
80
80
|
end
|
@@ -90,18 +90,18 @@ describe Localeapp::Poller do
|
|
90
90
|
end
|
91
91
|
|
92
92
|
it "returns true" do
|
93
|
-
@poller.poll
|
93
|
+
expect(@poller.poll!).to eq(true)
|
94
94
|
end
|
95
95
|
|
96
96
|
it "updates the polled_at and the updated_at synchronization data" do
|
97
|
-
@poller.
|
98
|
-
@poller.
|
97
|
+
allow(@poller).to receive(:current_time).and_return(polled_at_time)
|
98
|
+
expect(@poller).to receive(:write_synchronization_data!).with(polled_at_time, updated_at_time)
|
99
99
|
@poller.poll!
|
100
100
|
end
|
101
101
|
|
102
102
|
it "passes the data through to the Updater" do
|
103
103
|
FakeWeb.register_uri(:get, "https://api.localeapp.com/v1/projects/TEST_KEY/translations.yml?updated_at=#{@updated_at}", :body => @hash.to_yaml, :status => ['200', 'OK'], :date => Time.now.httpdate)
|
104
|
-
Localeapp.updater.
|
104
|
+
expect(Localeapp.updater).to receive(:update).with(@hash)
|
105
105
|
@poller.poll!
|
106
106
|
end
|
107
107
|
end
|
@@ -19,7 +19,7 @@ describe Localeapp::Rails::Controller, '#handle_translation_updates' do
|
|
19
19
|
with_configuration(configuration) do
|
20
20
|
@controller = TestController.new
|
21
21
|
end
|
22
|
-
now = Time.now; Time.
|
22
|
+
now = Time.now; allow(Time).to receive(:now).and_return(now)
|
23
23
|
end
|
24
24
|
|
25
25
|
after do
|
@@ -33,12 +33,12 @@ describe Localeapp::Rails::Controller, '#handle_translation_updates' do
|
|
33
33
|
|
34
34
|
it "calls poller.poll! when the synchronization file's polled_at has changed" do
|
35
35
|
Localeapp.poller.write_synchronization_data!(01234, 56789)
|
36
|
-
Localeapp.poller.
|
36
|
+
expect(Localeapp.poller).to receive(:poll!)
|
37
37
|
@controller.handle_translation_updates
|
38
38
|
end
|
39
39
|
|
40
40
|
it "doesn't call poller.poll! when the synchronization file's polled_at is the same" do
|
41
|
-
Localeapp.poller.
|
41
|
+
expect(Localeapp.poller).not_to receive(:poll!)
|
42
42
|
@controller.handle_translation_updates
|
43
43
|
end
|
44
44
|
end
|
@@ -50,12 +50,12 @@ describe Localeapp::Rails::Controller, '#handle_translation_updates' do
|
|
50
50
|
|
51
51
|
it "doesn't poller.poll! when the synchronization file's polled_at has changed" do
|
52
52
|
Localeapp.poller.write_synchronization_data!(01234, 56789)
|
53
|
-
Localeapp.poller.
|
53
|
+
expect(Localeapp.poller).not_to receive(:poll!)
|
54
54
|
@controller.handle_translation_updates
|
55
55
|
end
|
56
56
|
|
57
57
|
it "doesn't poller.poll! when the synchronization file's polled_at is the same" do
|
58
|
-
Localeapp.poller.
|
58
|
+
expect(Localeapp.poller).not_to receive(:poll!)
|
59
59
|
@controller.handle_translation_updates
|
60
60
|
end
|
61
61
|
end
|
@@ -63,17 +63,17 @@ describe Localeapp::Rails::Controller, '#handle_translation_updates' do
|
|
63
63
|
context "when reloading is enabled" do
|
64
64
|
before do
|
65
65
|
Localeapp.configuration.environment_name = 'development'
|
66
|
-
Localeapp.poller.
|
66
|
+
allow(Localeapp.poller).to receive(:poll!)
|
67
67
|
end
|
68
68
|
|
69
69
|
it "calls I18n.reload! when the synchronization file's updated_at has changed" do
|
70
70
|
Localeapp.poller.write_synchronization_data!(01234, 56789)
|
71
|
-
I18n.
|
71
|
+
expect(I18n).to receive(:reload!)
|
72
72
|
@controller.handle_translation_updates
|
73
73
|
end
|
74
74
|
|
75
75
|
it "doesn't call I18n.relaod! when the synchronization file's updated_at is the same" do
|
76
|
-
I18n.
|
76
|
+
expect(I18n).not_to receive(:reload!)
|
77
77
|
@controller.handle_translation_updates
|
78
78
|
end
|
79
79
|
end
|
@@ -85,12 +85,12 @@ describe Localeapp::Rails::Controller, '#handle_translation_updates' do
|
|
85
85
|
|
86
86
|
it "doesn't call I18n.reload! when the synchronization file's updated_at has changed" do
|
87
87
|
Localeapp.poller.write_synchronization_data!(01234, 56789)
|
88
|
-
I18n.
|
88
|
+
expect(I18n).not_to receive(:reload!)
|
89
89
|
@controller.handle_translation_updates
|
90
90
|
end
|
91
91
|
|
92
92
|
it "doesn't call I18n.relaod! when the synchronization file's updated_at is the same" do
|
93
|
-
I18n.
|
93
|
+
expect(I18n).not_to receive(:reload!)
|
94
94
|
@controller.handle_translation_updates
|
95
95
|
end
|
96
96
|
end
|
@@ -127,19 +127,19 @@ describe Localeapp::Rails::Controller, '#send_missing_translations' do
|
|
127
127
|
|
128
128
|
it "does nothing when sending is disabled" do
|
129
129
|
Localeapp.configuration.environment_name = 'test'
|
130
|
-
Localeapp.sender.
|
130
|
+
expect(Localeapp.sender).not_to receive(:post_missing_translations)
|
131
131
|
@controller.send_missing_translations
|
132
132
|
end
|
133
133
|
|
134
134
|
it "proceeds when configuration is enabled" do
|
135
135
|
Localeapp.configuration.environment_name = 'development'
|
136
|
-
Localeapp.sender.
|
136
|
+
expect(Localeapp.sender).to receive(:post_missing_translations)
|
137
137
|
@controller.send_missing_translations
|
138
138
|
end
|
139
139
|
|
140
140
|
it "rejects blacklisted translations" do
|
141
141
|
Localeapp.configuration.environment_name = 'development'
|
142
|
-
Localeapp.missing_translations.
|
142
|
+
expect(Localeapp.missing_translations).to receive(:reject_blacklisted)
|
143
143
|
@controller.send_missing_translations
|
144
144
|
end
|
145
145
|
end
|
@@ -14,8 +14,8 @@ describe Localeapp::Routes do
|
|
14
14
|
it "returns :get and the project url for the options" do
|
15
15
|
with_configuration(@config) do
|
16
16
|
options = { :foo => :bar }
|
17
|
-
@routes.
|
18
|
-
@routes.project_endpoint(options).
|
17
|
+
expect(@routes).to receive(:project_url).with(options).and_return('url')
|
18
|
+
expect(@routes.project_endpoint(options)).to eq([:get, 'url'])
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
@@ -23,19 +23,19 @@ describe Localeapp::Routes do
|
|
23
23
|
describe '#project_url' do
|
24
24
|
it "is constructed from the configuration host, port and secure and defaults to json" do
|
25
25
|
with_configuration(@config.merge(:port => 1234, :secure => false)) do
|
26
|
-
@routes.project_url.
|
26
|
+
expect(@routes.project_url).to eq("http://test.host:1234/v1/projects/API_KEY.json")
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
30
|
it "includes http auth if in configuration" do
|
31
31
|
with_configuration(@config.merge(:port => 1234, :http_auth_username => 'foo', :http_auth_password => 'bar')) do
|
32
|
-
@routes.project_url.
|
32
|
+
expect(@routes.project_url).to eq("https://foo:bar@test.host:1234/v1/projects/API_KEY.json")
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
36
|
it "can be changed to another content type" do
|
37
37
|
with_configuration(@config) do
|
38
|
-
@routes.project_url(:format => :yml).
|
38
|
+
expect(@routes.project_url(:format => :yml)).to eq('https://test.host/v1/projects/API_KEY.yml')
|
39
39
|
end
|
40
40
|
end
|
41
41
|
end
|
@@ -43,21 +43,21 @@ describe Localeapp::Routes do
|
|
43
43
|
describe "#translations_url" do
|
44
44
|
it "it extends the project_url and defaults to yml" do
|
45
45
|
with_configuration(@config) do
|
46
|
-
@routes.translations_url.
|
46
|
+
expect(@routes.translations_url).to eq("https://test.host/v1/projects/API_KEY/translations.yml")
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
50
|
it "adds query parameters on to the url" do
|
51
51
|
with_configuration(@config) do
|
52
52
|
url = @routes.translations_url(:query => {:updated_at => '2011-04-19', :foo => :bar})
|
53
|
-
url.
|
54
|
-
url.
|
53
|
+
expect(url).to match(/\?.*updated_at=2011-04-19/)
|
54
|
+
expect(url).to match(/\?.*foo=bar/)
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
58
|
it "can be changed to another content type" do
|
59
59
|
with_configuration(@config) do
|
60
|
-
@routes.translations_url(:format => :json).
|
60
|
+
expect(@routes.translations_url(:format => :json)).to eq('https://test.host/v1/projects/API_KEY/translations.json')
|
61
61
|
end
|
62
62
|
end
|
63
63
|
end
|
@@ -66,8 +66,8 @@ describe Localeapp::Routes do
|
|
66
66
|
it "returns :get and the translations url for the options" do
|
67
67
|
with_configuration(@config) do
|
68
68
|
options = { :foo => :bar }
|
69
|
-
@routes.
|
70
|
-
@routes.translations_endpoint(options).
|
69
|
+
expect(@routes).to receive(:translations_url).with(options).and_return('url')
|
70
|
+
expect(@routes.translations_endpoint(options)).to eq([:get, 'url'])
|
71
71
|
end
|
72
72
|
end
|
73
73
|
end
|
@@ -76,8 +76,8 @@ describe Localeapp::Routes do
|
|
76
76
|
it "returns :post and the translation url for the options" do
|
77
77
|
with_configuration(@config) do
|
78
78
|
options = { :foo => :bar }
|
79
|
-
@routes.
|
80
|
-
@routes.create_translation_endpoint(options).
|
79
|
+
expect(@routes).to receive(:translations_url).with(options).and_return('url')
|
80
|
+
expect(@routes.create_translation_endpoint(options)).to eq([:post, 'url'])
|
81
81
|
end
|
82
82
|
end
|
83
83
|
end
|
@@ -86,8 +86,8 @@ describe Localeapp::Routes do
|
|
86
86
|
it "returns :delete and the remove url for the options" do
|
87
87
|
with_configuration(@config) do
|
88
88
|
options = { :key => 'foo.bar' }
|
89
|
-
@routes.
|
90
|
-
@routes.remove_endpoint(options).
|
89
|
+
expect(@routes).to receive(:remove_url).with(options).and_return('url')
|
90
|
+
expect(@routes.remove_endpoint(options)).to eq([:delete, 'url'])
|
91
91
|
end
|
92
92
|
end
|
93
93
|
end
|
@@ -95,7 +95,7 @@ describe Localeapp::Routes do
|
|
95
95
|
describe "#remove_url(options = {})" do
|
96
96
|
it "it extends the project_url and includes the escaped key name" do
|
97
97
|
with_configuration(@config) do
|
98
|
-
@routes.remove_url(:key => 'test.key').
|
98
|
+
expect(@routes.remove_url(:key => 'test.key')).to eq("https://test.host/v1/projects/API_KEY/translations/test%2Ekey")
|
99
99
|
end
|
100
100
|
end
|
101
101
|
end
|
@@ -104,8 +104,8 @@ describe Localeapp::Routes do
|
|
104
104
|
it "returns :post and the rename url for the options" do
|
105
105
|
with_configuration(@config) do
|
106
106
|
options = { :current_name => 'foo.bar' }
|
107
|
-
@routes.
|
108
|
-
@routes.rename_endpoint(options).
|
107
|
+
expect(@routes).to receive(:rename_url).with(options).and_return('url')
|
108
|
+
expect(@routes.rename_endpoint(options)).to eq([:post, 'url'])
|
109
109
|
end
|
110
110
|
end
|
111
111
|
end
|
@@ -113,7 +113,7 @@ describe Localeapp::Routes do
|
|
113
113
|
describe "#rename_url(options = {})" do
|
114
114
|
it "it extends the project_url and includes the escaped key name" do
|
115
115
|
with_configuration(@config) do
|
116
|
-
@routes.rename_url(:current_name => 'test.key').
|
116
|
+
expect(@routes.rename_url(:current_name => 'test.key')).to eq("https://test.host/v1/projects/API_KEY/translations/test%2Ekey/rename")
|
117
117
|
end
|
118
118
|
end
|
119
119
|
end
|
@@ -121,21 +121,21 @@ describe Localeapp::Routes do
|
|
121
121
|
describe "#export_url" do
|
122
122
|
it "it extends the project_url and defaults to yml" do
|
123
123
|
with_configuration(@config) do
|
124
|
-
@routes.export_url.
|
124
|
+
expect(@routes.export_url).to eq("https://test.host/v1/projects/API_KEY/translations/all.yml")
|
125
125
|
end
|
126
126
|
end
|
127
127
|
|
128
128
|
it "adds query parameters on to the url" do
|
129
129
|
with_configuration(@config) do
|
130
130
|
url = @routes.export_url(:query => {:updated_at => '2011-04-19', :foo => :bar})
|
131
|
-
url.
|
132
|
-
url.
|
131
|
+
expect(url).to match(/\?.*updated_at=2011-04-19/)
|
132
|
+
expect(url).to match(/\?.*foo=bar/)
|
133
133
|
end
|
134
134
|
end
|
135
135
|
|
136
136
|
it "can be changed to another content type" do
|
137
137
|
with_configuration(@config) do
|
138
|
-
@routes.export_url(:format => :json).
|
138
|
+
expect(@routes.export_url(:format => :json)).to eq('https://test.host/v1/projects/API_KEY/translations/all.json')
|
139
139
|
end
|
140
140
|
end
|
141
141
|
end
|
@@ -144,8 +144,8 @@ describe Localeapp::Routes do
|
|
144
144
|
it "returns :get and the export url for the options" do
|
145
145
|
with_configuration(@config) do
|
146
146
|
options = { :foo => :bar }
|
147
|
-
@routes.
|
148
|
-
@routes.export_endpoint(options).
|
147
|
+
expect(@routes).to receive(:export_url).with(options).and_return('url')
|
148
|
+
expect(@routes.export_endpoint(options)).to eq([:get, 'url'])
|
149
149
|
end
|
150
150
|
end
|
151
151
|
end
|
@@ -154,8 +154,8 @@ describe Localeapp::Routes do
|
|
154
154
|
it "returns :post and the missing_translations url for the options" do
|
155
155
|
with_configuration(@config) do
|
156
156
|
options = { :foo => :bar }
|
157
|
-
@routes.
|
158
|
-
@routes.missing_translations_endpoint(options).
|
157
|
+
expect(@routes).to receive(:missing_translations_url).with(options).and_return('url')
|
158
|
+
expect(@routes.missing_translations_endpoint(options)).to eq([:post, 'url'])
|
159
159
|
end
|
160
160
|
end
|
161
161
|
end
|
@@ -163,21 +163,21 @@ describe Localeapp::Routes do
|
|
163
163
|
describe "#missing_translations_url" do
|
164
164
|
it "it extends the project_url and defaults to json" do
|
165
165
|
with_configuration(@config) do
|
166
|
-
@routes.missing_translations_url.
|
166
|
+
expect(@routes.missing_translations_url).to eq("https://test.host/v1/projects/API_KEY/translations/missing.json")
|
167
167
|
end
|
168
168
|
end
|
169
169
|
|
170
170
|
it "adds query parameters on to the url" do
|
171
171
|
with_configuration(@config) do
|
172
172
|
url = @routes.missing_translations_url(:query => {:updated_at => '2011-04-19', :foo => :bar})
|
173
|
-
url.
|
174
|
-
url.
|
173
|
+
expect(url).to match(/\?.*updated_at=2011-04-19/)
|
174
|
+
expect(url).to match(/\?.*foo=bar/)
|
175
175
|
end
|
176
176
|
end
|
177
177
|
|
178
178
|
it "can be changed to another content type" do
|
179
179
|
with_configuration(@config) do
|
180
|
-
@routes.missing_translations_url(:format => :yml).
|
180
|
+
expect(@routes.missing_translations_url(:format => :yml)).to eq('https://test.host/v1/projects/API_KEY/translations/missing.yml')
|
181
181
|
end
|
182
182
|
end
|
183
183
|
end
|
@@ -185,7 +185,7 @@ describe Localeapp::Routes do
|
|
185
185
|
describe "#import_url" do
|
186
186
|
it "appends 'import to the project url" do
|
187
187
|
with_configuration(@config) do
|
188
|
-
@routes.import_url.
|
188
|
+
expect(@routes.import_url).to eq('https://test.host/v1/projects/API_KEY/import/')
|
189
189
|
end
|
190
190
|
end
|
191
191
|
end
|
@@ -194,8 +194,8 @@ describe Localeapp::Routes do
|
|
194
194
|
it "returns :post and the import url for the options" do
|
195
195
|
with_configuration(@config) do
|
196
196
|
options = { :foo => :bar }
|
197
|
-
@routes.
|
198
|
-
@routes.import_endpoint(options).
|
197
|
+
expect(@routes).to receive(:import_url).with(options).and_return('url')
|
198
|
+
expect(@routes.import_endpoint(options)).to eq([:post, 'url'])
|
199
199
|
end
|
200
200
|
end
|
201
201
|
end
|