copycopter_client 1.0.0.beta2 → 1.0.0.beta3
Sign up to get free protection for your applications and to get access to all the features.
data/features/rails.feature
CHANGED
@@ -106,13 +106,15 @@ Feature: Using copycopter in a rails app
|
|
106
106
|
|
107
107
|
Scenario: copycopter in production
|
108
108
|
Given the "abc123" project has the following blurbs:
|
109
|
-
| key
|
110
|
-
| en.users.index.controller-test
|
109
|
+
| key | published content | draft content |
|
110
|
+
| en.users.index.controller-test | This is a test | Extra extra |
|
111
|
+
| en.users.index.unpublished-test | | Extra extra |
|
111
112
|
When I write to "app/controllers/users_controller.rb" with:
|
112
113
|
"""
|
113
114
|
class UsersController < ActionController::Base
|
114
115
|
def index
|
115
116
|
@text = t("users.index.controller-test", :default => "default")
|
117
|
+
@unpublished = t("users.index.unpublished-test", :default => "Unpublished")
|
116
118
|
end
|
117
119
|
end
|
118
120
|
"""
|
@@ -120,12 +122,14 @@ Feature: Using copycopter in a rails app
|
|
120
122
|
And I write to "app/views/users/index.html.erb" with:
|
121
123
|
"""
|
122
124
|
<%= @text %>
|
125
|
+
<%= @unpublished %>
|
123
126
|
"""
|
124
127
|
When I configure the copycopter client to use published data
|
125
128
|
And I start the application
|
126
129
|
And I wait for changes to be synchronized
|
127
130
|
And I visit /users/
|
128
131
|
Then the response should contain "This is a test"
|
132
|
+
And the response should contain "Unpublished"
|
129
133
|
|
130
134
|
Scenario: backwards compatibility
|
131
135
|
Given the "abc123" project has the following blurbs:
|
@@ -94,6 +94,7 @@ module CopycopterClient
|
|
94
94
|
def poll
|
95
95
|
until @stop
|
96
96
|
sync
|
97
|
+
logger.flush if logger.respond_to?(:flush)
|
97
98
|
sleep(polling_delay)
|
98
99
|
end
|
99
100
|
rescue InvalidApiKey => error
|
@@ -102,8 +103,7 @@ module CopycopterClient
|
|
102
103
|
|
103
104
|
def sync
|
104
105
|
begin
|
105
|
-
|
106
|
-
lock { @blurbs = downloaded_blurbs }
|
106
|
+
download
|
107
107
|
flush
|
108
108
|
rescue ConnectionError => error
|
109
109
|
logger.error(error.message)
|
@@ -123,6 +123,12 @@ module CopycopterClient
|
|
123
123
|
yield(changes_to_push) if changes_to_push
|
124
124
|
end
|
125
125
|
|
126
|
+
def download
|
127
|
+
downloaded_blurbs = client.download
|
128
|
+
downloaded_blurbs.reject! { |key, value| value == "" }
|
129
|
+
lock { @blurbs = downloaded_blurbs }
|
130
|
+
end
|
131
|
+
|
126
132
|
def lock(&block)
|
127
133
|
@mutex.synchronize(&block)
|
128
134
|
end
|
@@ -22,4 +22,16 @@ describe CopycopterClient::PrefixedLogger do
|
|
22
22
|
output_logger.should have_entry(level, "#{prefix} #{thread_info} #{message}")
|
23
23
|
end
|
24
24
|
end
|
25
|
+
|
26
|
+
it "calls flush for a logger that responds to flush" do
|
27
|
+
output_logger.stubs(:flush)
|
28
|
+
|
29
|
+
subject.flush
|
30
|
+
|
31
|
+
output_logger.should have_received(:flush)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "doesn't call flush for a logger that doesn't respond to flush" do
|
35
|
+
lambda { subject.flush }.should_not raise_error
|
36
|
+
end
|
25
37
|
end
|
@@ -176,6 +176,7 @@ describe CopycopterClient::Sync do
|
|
176
176
|
default_config = CopycopterClient::Configuration.new.to_hash.update(config)
|
177
177
|
real_client = CopycopterClient::Client.new(default_config)
|
178
178
|
sync = CopycopterClient::Sync.new(real_client, default_config)
|
179
|
+
sync.stubs(:at_exit)
|
179
180
|
CopycopterClient.sync = sync
|
180
181
|
job.sync = sync
|
181
182
|
|
@@ -194,7 +195,6 @@ describe CopycopterClient::Sync do
|
|
194
195
|
|
195
196
|
project = FakeCopycopterApp.project(api_key)
|
196
197
|
project.draft['test.key'].should == 'all your base'
|
197
|
-
|
198
198
|
end
|
199
199
|
|
200
200
|
it "starts after spawning when using unicorn" do
|
@@ -285,6 +285,27 @@ describe CopycopterClient::Sync do
|
|
285
285
|
logger.should have_entry(:error, "Couldn't start poller thread")
|
286
286
|
end
|
287
287
|
|
288
|
+
it "flushes the log when polling" do
|
289
|
+
logger = FakeLogger.new
|
290
|
+
logger.stubs(:flush)
|
291
|
+
sync = build_sync(:polling_delay => 1, :logger => logger)
|
292
|
+
|
293
|
+
sync.start
|
294
|
+
sleep(2)
|
295
|
+
|
296
|
+
logger.should have_received(:flush).at_least_once
|
297
|
+
end
|
298
|
+
|
299
|
+
it "doesn't return blank copy" do
|
300
|
+
client['en.test.key'] = ''
|
301
|
+
sync = build_sync(:polling_delay => 1)
|
302
|
+
|
303
|
+
sync.start
|
304
|
+
sleep(2)
|
305
|
+
|
306
|
+
sync['en.test.key'].should be_nil
|
307
|
+
end
|
308
|
+
|
288
309
|
describe "given locked mutex" do
|
289
310
|
Spec::Matchers.define :finish_after_unlocking do |mutex|
|
290
311
|
match do |thread|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: copycopter_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 299253595
|
5
5
|
prerelease: true
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
9
|
- 0
|
10
|
-
-
|
11
|
-
version: 1.0.0.
|
10
|
+
- beta3
|
11
|
+
version: 1.0.0.beta3
|
12
12
|
platform: ruby
|
13
13
|
authors:
|
14
14
|
- thoughtbot
|