flash_flow 1.4.8 → 1.4.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,62 @@
1
+ require 'minitest_helper'
2
+ require 'flash_flow/release/pdf_diff_generator'
3
+ require 'fileutils'
4
+ require 'open-uri'
5
+
6
+ module FlashFlow
7
+ module Release
8
+ class TestPdfDiffGenerator < Minitest::Test
9
+
10
+ def test_gen_pdf_diffs
11
+ PdfDiffGenerator.new.generate(compare_response, '/tmp/test_build_diffs.pdf', 0.0, false)
12
+ end
13
+
14
+ def test_convert_response
15
+ # localize_resources('test/fixtures/pdf_diff_test_1.json', 'test/fixtures/pdf_diff/')
16
+ end
17
+
18
+ private
19
+
20
+ def compare_response
21
+ file = File.read('test/fixtures/pdf_diff/pdf_diff_test_1.json')
22
+ JSON.parse(file)
23
+ end
24
+
25
+ def localize_resources(source_file, location, threshold=0.0)
26
+ pdf_generator = PdfDiffGenerator.new
27
+ source_data = File.read(source_file)
28
+ source_json = JSON.parse(source_data)
29
+ info = pdf_generator.send(:collect_comparison_info, source_json, threshold)
30
+
31
+ create_destination(location)
32
+
33
+ info.each do |row|
34
+ %w(head-screenshot base-screenshot pdiff).each do |attr|
35
+ source_url = row.dig(attr, :url)
36
+ target = File.join(location, "#{source_url.split('/').last}.png")
37
+ # Copy the file locally if it doesn't exist
38
+ unless File.exists?(target)
39
+ open(target, 'wb') do |file|
40
+ file << open(source_url).read
41
+ end
42
+ end
43
+ # Use our local copy instead of the remote url
44
+ source_data.sub(source_url, target)
45
+ end
46
+ end
47
+
48
+ # Write out our new test data with only local references
49
+ target = File.join(location, File.basename(source_file))
50
+ open(target, 'w') { |file| file << source_data } unless File.exists?(target)
51
+ end
52
+
53
+ def create_destination(location)
54
+ unless File.directory?(location)
55
+ FileUtils.mkdir_p(location)
56
+ end
57
+ end
58
+
59
+ end
60
+ end
61
+ end
62
+
@@ -30,7 +30,7 @@ module FlashFlow
30
30
  .expect(:get_sha, 'bbbbb', ['release'])
31
31
 
32
32
  @mailer = Minitest::Mock.new
33
- @mailer.expect(:deliver!, true, [{percy_build_url: 'https://percy.io/repo/builds/1111'}])
33
+ @mailer.expect(:deliver!, true, [:compliance, {percy_build_url: 'https://percy.io/repo/builds/1111'}])
34
34
 
35
35
  @percy_client.instance_variable_set('@git'.to_sym, @git)
36
36
  @percy_client.instance_variable_set('@mailer'.to_sym, @mailer)
@@ -66,6 +66,12 @@ module FlashFlow
66
66
  end
67
67
  end
68
68
 
69
+ def test_qa_approved?
70
+ @percy_client.stub(:get_builds, sample_response) do
71
+ assert(@percy_client.send(:qa_approved?, 'aaaaa'))
72
+ end
73
+ end
74
+
69
75
  private
70
76
 
71
77
  def sample_response
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flash_flow
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.8
4
+ version: 1.4.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Flashfunders
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-15 00:00:00.000000000 Z
11
+ date: 2016-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: octokit
@@ -234,6 +234,14 @@ files:
234
234
  - lib/flash_flow/time_helper.rb
235
235
  - lib/flash_flow/version.rb
236
236
  - log/.keep
237
+ - test/fixtures/pdf_diff/0cbafd97ee4904001e47c0d7a4a6e4b2ee7ed830458c8616466f7a631dfeb3ce.png
238
+ - test/fixtures/pdf_diff/142ef42e828a35e3e128f47277cb73e56215f5a81c53923c657634ac574cca07.png
239
+ - test/fixtures/pdf_diff/59df070cbe2188a9f584ecdabe553da00d3e9b353d3b745448ad81a0028f05fa.png
240
+ - test/fixtures/pdf_diff/6942084eb617d86454bafdfb7dfb820567a1c9361068d6552449912b631e9ad1.png
241
+ - test/fixtures/pdf_diff/75adb2b47ff19687249a4e95ed7f1b7aa92abf5e74a806d2cbd9e2d9aa569cb1.png
242
+ - test/fixtures/pdf_diff/a7501e15821c22aead2030676403b54da8c99c6967f3d95e1040cc62f9c089a6.png
243
+ - test/fixtures/pdf_diff/pdf_diff_test_1.json
244
+ - test/fixtures/pdf_diff_test_1.json
237
245
  - test/lib/data/test_base.rb
238
246
  - test/lib/data/test_branch.rb
239
247
  - test/lib/data/test_collection.rb
@@ -244,7 +252,7 @@ files:
244
252
  - test/lib/merge/test_acceptance.rb
245
253
  - test/lib/merge/test_release_graph.rb
246
254
  - test/lib/merge/test_status.rb
247
- - test/lib/release/test_pdf_diff_generator.rb
255
+ - test/lib/release/pdf_diff_generator_testing.rb
248
256
  - test/lib/release/test_percy_client.rb
249
257
  - test/lib/test_branch_merger.rb
250
258
  - test/lib/test_config.rb
@@ -280,6 +288,14 @@ signing_key:
280
288
  specification_version: 4
281
289
  summary: Implementation of the flashfunders workflow
282
290
  test_files:
291
+ - test/fixtures/pdf_diff/0cbafd97ee4904001e47c0d7a4a6e4b2ee7ed830458c8616466f7a631dfeb3ce.png
292
+ - test/fixtures/pdf_diff/142ef42e828a35e3e128f47277cb73e56215f5a81c53923c657634ac574cca07.png
293
+ - test/fixtures/pdf_diff/59df070cbe2188a9f584ecdabe553da00d3e9b353d3b745448ad81a0028f05fa.png
294
+ - test/fixtures/pdf_diff/6942084eb617d86454bafdfb7dfb820567a1c9361068d6552449912b631e9ad1.png
295
+ - test/fixtures/pdf_diff/75adb2b47ff19687249a4e95ed7f1b7aa92abf5e74a806d2cbd9e2d9aa569cb1.png
296
+ - test/fixtures/pdf_diff/a7501e15821c22aead2030676403b54da8c99c6967f3d95e1040cc62f9c089a6.png
297
+ - test/fixtures/pdf_diff/pdf_diff_test_1.json
298
+ - test/fixtures/pdf_diff_test_1.json
283
299
  - test/lib/data/test_base.rb
284
300
  - test/lib/data/test_branch.rb
285
301
  - test/lib/data/test_collection.rb
@@ -290,7 +306,7 @@ test_files:
290
306
  - test/lib/merge/test_acceptance.rb
291
307
  - test/lib/merge/test_release_graph.rb
292
308
  - test/lib/merge/test_status.rb
293
- - test/lib/release/test_pdf_diff_generator.rb
309
+ - test/lib/release/pdf_diff_generator_testing.rb
294
310
  - test/lib/release/test_percy_client.rb
295
311
  - test/lib/test_branch_merger.rb
296
312
  - test/lib/test_config.rb