judges 0.47.0 → 0.49.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.
@@ -20,11 +20,12 @@ class TestDownload < Minitest::Test
20
20
  stub_request(:get, 'https://example.org/durables/find?file=downloaded.txt&jname=myjudge').to_return(
21
21
  status: 200, body: '42'
22
22
  )
23
- stub_request(:get, 'https://example.org/durables/42/lock?owner=default').to_return(status: 302)
23
+ stub_request(:get, 'https://example.org/csrf').to_return(body: 'test-csrf-token')
24
+ stub_request(:post, %r{https://example.org/durables/42/lock}).to_return(status: 302)
24
25
  stub_request(:get, 'https://example.org/durables/42').to_return(
25
- status: 200, body: content
26
+ status: 200, body: content, headers: {}
26
27
  )
27
- stub_request(:get, 'https://example.org/durables/42/unlock?owner=default').to_return(status: 302)
28
+ stub_request(:post, %r{https://example.org/durables/42/unlock}).to_return(status: 302)
28
29
  Dir.mktmpdir do |d|
29
30
  file = File.join(d, 'downloaded.txt')
30
31
  Judges::Download.new(Loog::NULL).run(
@@ -44,14 +45,15 @@ class TestDownload < Minitest::Test
44
45
  def test_download_with_custom_owner
45
46
  WebMock.disable_net_connect!
46
47
  content = 'Custom content'
47
- stub_request(:get, 'http://example.org/durables/find?file=data.bin&jname=judge1').to_return(
48
+ stub_request(:get, %r{http://example.org/durables/find}).to_return(
48
49
  status: 200, body: '123'
49
50
  )
50
- stub_request(:get, 'http://example.org/durables/123/lock?owner=custom').to_return(status: 302)
51
+ stub_request(:get, 'http://example.org/csrf').to_return(body: 'test-csrf-token')
52
+ stub_request(:post, %r{http://example.org/durables/123/lock}).to_return(status: 302)
51
53
  stub_request(:get, 'http://example.org/durables/123').to_return(
52
- status: 200, body: content
54
+ status: 200, body: content, headers: {}
53
55
  )
54
- stub_request(:get, 'http://example.org/durables/123/unlock?owner=custom').to_return(status: 302)
56
+ stub_request(:post, %r{http://example.org/durables/123/unlock}).to_return(status: 302)
55
57
  Dir.mktmpdir do |d|
56
58
  file = File.join(d, 'data.bin')
57
59
  Judges::Download.new(Loog::NULL).run(
@@ -73,9 +75,10 @@ class TestDownload < Minitest::Test
73
75
  stub_request(:get, 'http://example.org/durables/find?file=test.txt&jname=somejudge').to_return(
74
76
  status: 200, body: '99'
75
77
  )
76
- stub_request(:get, 'http://example.org/durables/99/lock?owner=none').to_return(status: 302)
78
+ stub_request(:get, 'http://example.org/csrf').to_return(body: 'test-csrf-token')
79
+ stub_request(:post, %r{http://example.org/durables/99/lock}).to_return(status: 302)
77
80
  stub_request(:get, 'http://example.org/durables/99').to_return(status: 404)
78
- stub_request(:get, 'http://example.org/durables/99/unlock?owner=none').to_return(status: 302)
81
+ stub_request(:post, %r{http://example.org/durables/99/unlock}).to_return(status: 302)
79
82
  Dir.mktmpdir do |d|
80
83
  file = File.join(d, 'test.txt')
81
84
  assert_raises(StandardError) do
@@ -79,6 +79,35 @@ class TestPrint < Minitest::Test
79
79
  assert_empty(v.errors, "#{doc}\n\n#{v.errors.join('; ')}")
80
80
  end
81
81
 
82
+ def test_html_table_has_colgroup
83
+ WebMock.disable_net_connect!
84
+ stub_request(:get, 'https://yegor256.github.io/judges/assets/index.css').to_return(body: 'nothing')
85
+ stub_request(:get, 'https://yegor256.github.io/judges/assets/index.js').to_return(body: 'nothing')
86
+ fb = Factbase.new
87
+ f = fb.insert
88
+ f.what = 'test issue'
89
+ f.when = Time.now
90
+ f.ticket = 42
91
+ html = File.join(__dir__, '../../temp/colgroup_test.html')
92
+ FileUtils.rm_f(html)
93
+ Dir.mktmpdir do |d|
94
+ factbase_file = File.join(d, 'base.fb')
95
+ File.binwrite(factbase_file, fb.export)
96
+ Judges::Print.new(Loog::NULL).run(
97
+ { 'format' => 'html', 'columns' => 'what,when,ticket' },
98
+ [factbase_file, html]
99
+ )
100
+ end
101
+ doc = Nokogiri::HTML(File.read(html))
102
+ table = doc.at_css('table#facts')
103
+ refute_nil(table, 'Table with id="facts" should exist')
104
+ colgroup = table.at_css('colgroup')
105
+ refute_nil(colgroup, 'Table should have a colgroup element')
106
+ cols = colgroup.css('col')
107
+ assert_equal(4, cols.size, 'Should have 4 col elements (3 for columns + 1 for extra)')
108
+ assert_equal('w50', cols.last['class'], 'Last col should have class="w50"')
109
+ end
110
+
82
111
  def test_print_all_formats
83
112
  WebMock.disable_net_connect!
84
113
  stub_request(:get, 'https://yegor256.github.io/judges/assets/index.css').to_return(body: 'nothing')
@@ -17,15 +17,16 @@ require_relative '../test__helper'
17
17
  class TestPull < Minitest::Test
18
18
  def test_pull_simple_factbase
19
19
  WebMock.disable_net_connect!
20
- stub_request(:get, 'http://example.org/lock/foo?owner=none').to_return(status: 302)
20
+ stub_request(:get, 'http://example.org/csrf').to_return(body: 'test-csrf-token')
21
+ stub_request(:post, %r{http://example.org/lock/foo}).to_return(status: 302)
21
22
  stub_request(:get, 'http://example.org/exists/foo').to_return(body: 'yes')
22
23
  stub_request(:get, 'http://example.org/recent/foo.txt').to_return(body: '42')
23
24
  stub_request(:get, 'http://example.org/finished/42').to_return(body: 'yes')
24
25
  stub_request(:get, 'http://example.org/exit/42.txt').to_return(body: '0')
25
- stub_request(:get, 'http://example.org/unlock/foo?owner=none').to_return(status: 302)
26
+ stub_request(:post, %r{http://example.org/unlock/foo}).to_return(status: 302)
26
27
  fb = Factbase.new
27
28
  fb.insert.foo = 42
28
- stub_request(:get, 'http://example.org/pull/42.fb').to_return(body: fb.export)
29
+ stub_request(:get, 'http://example.org/pull/42.fb').to_return(body: fb.export, headers: {})
29
30
  Dir.mktmpdir do |d|
30
31
  file = File.join(d, 'base.fb')
31
32
  Judges::Pull.new(Loog::NULL).run(
@@ -46,13 +47,14 @@ class TestPull < Minitest::Test
46
47
 
47
48
  def test_fail_pull_when_job_is_broken
48
49
  WebMock.disable_net_connect!
49
- stub_request(:get, 'http://example.org/lock/foo?owner=none').to_return(status: 302)
50
+ stub_request(:get, 'http://example.org/csrf').to_return(body: 'test-csrf-token')
51
+ stub_request(:post, %r{http://example.org/lock/foo}).to_return(status: 302)
50
52
  stub_request(:get, 'http://example.org/exists/foo').to_return(body: 'yes')
51
53
  stub_request(:get, 'http://example.org/recent/foo.txt').to_return(body: '42')
52
54
  stub_request(:get, 'http://example.org/finished/42').to_return(body: 'yes')
53
55
  stub_request(:get, 'http://example.org/exit/42.txt').to_return(body: '1')
54
56
  stub_request(:get, 'http://example.org/stdout/42.txt').to_return(body: 'oops, some trouble here')
55
- stub_request(:get, 'http://example.org/unlock/foo?owner=none').to_return(status: 302)
57
+ stub_request(:post, %r{http://example.org/unlock/foo}).to_return(status: 302)
56
58
  Dir.mktmpdir do |d|
57
59
  file = File.join(d, 'base.fb')
58
60
  e =
@@ -16,8 +16,9 @@ require_relative '../test__helper'
16
16
  class TestPush < Minitest::Test
17
17
  def test_push_simple_factbase
18
18
  WebMock.disable_net_connect!
19
- stub_request(:get, 'https://example.org/lock/foo?owner=none').to_return(status: 302)
20
- stub_request(:get, 'https://example.org/unlock/foo?owner=none').to_return(status: 302)
19
+ stub_request(:get, 'https://example.org/csrf').to_return(body: 'test-csrf-token')
20
+ stub_request(:post, %r{https://example.org/lock/foo}).to_return(status: 302)
21
+ stub_request(:post, %r{https://example.org/unlock/foo}).to_return(status: 302)
21
22
  stub_request(:put, 'https://example.org/push/foo').to_return(
22
23
  status: 200, body: '42'
23
24
  )
@@ -52,9 +53,10 @@ class TestPush < Minitest::Test
52
53
 
53
54
  def test_fails_on_http_error
54
55
  WebMock.disable_net_connect!
55
- stub_request(:get, 'http://example.org/lock/foo?owner=none').to_return(status: 302)
56
+ stub_request(:get, 'http://example.org/csrf').to_return(body: 'test-csrf-token')
57
+ stub_request(:post, %r{http://example.org/lock/foo}).to_return(status: 302)
56
58
  stub_request(:put, 'http://example.org/push/foo').to_return(status: 500)
57
- stub_request(:get, 'http://example.org/unlock/foo?owner=none').to_return(status: 302)
59
+ stub_request(:post, %r{http://example.org/unlock/foo}).to_return(status: 302)
58
60
  Dir.mktmpdir do |d|
59
61
  file = File.join(d, 'base.fb')
60
62
  fb = Factbase.new
@@ -20,12 +20,13 @@ class TestUpload < Minitest::Test
20
20
  stub_request(:get, 'https://example.org/durables/find?file=upload.txt&jname=myjudge').to_return(
21
21
  status: 404
22
22
  )
23
- stub_request(:get, 'https://example.org/csrf').to_return(
24
- status: 200, body: 'test-csrf-token'
25
- )
23
+ stub_request(:get, 'https://example.org/csrf').to_return(body: 'test-csrf-token')
26
24
  stub_request(:post, 'https://example.org/durables/place').to_return(
27
25
  status: 302, headers: { 'X-Zerocracy-DurableId' => '42' }
28
26
  )
27
+ stub_request(:post, %r{https://example.org/durables/42/lock}).to_return(status: 302)
28
+ stub_request(:put, %r{https://example.org/durables/42}).to_return(status: 200)
29
+ stub_request(:post, %r{https://example.org/durables/42/unlock}).to_return(status: 302)
29
30
  Dir.mktmpdir do |d|
30
31
  file = File.join(d, 'upload.txt')
31
32
  File.write(file, content)
@@ -48,9 +49,10 @@ class TestUpload < Minitest::Test
48
49
  stub_request(:get, 'http://example.org/durables/find?file=data.bin&jname=judge1').to_return(
49
50
  status: 200, body: '123'
50
51
  )
51
- stub_request(:get, 'http://example.org/durables/123/lock?owner=custom').to_return(status: 302)
52
+ stub_request(:get, 'http://example.org/csrf').to_return(body: 'test-csrf-token')
53
+ stub_request(:post, %r{http://example.org/durables/123/lock}).to_return(status: 302)
52
54
  stub_request(:put, 'http://example.org/durables/123').to_return(status: 200)
53
- stub_request(:get, 'http://example.org/durables/123/unlock?owner=custom').to_return(status: 302)
55
+ stub_request(:post, %r{http://example.org/durables/123/unlock}).to_return(status: 302)
54
56
  Dir.mktmpdir do |d|
55
57
  file = File.join(d, 'data.bin')
56
58
  File.write(file, content)
@@ -72,9 +74,7 @@ class TestUpload < Minitest::Test
72
74
  stub_request(:get, 'http://example.org/durables/find?file=test.txt&jname=somejudge').to_return(
73
75
  status: 404
74
76
  )
75
- stub_request(:get, 'http://example.org/csrf').to_return(
76
- status: 200, body: 'test-csrf-token'
77
- )
77
+ stub_request(:get, 'http://example.org/csrf').to_return(body: 'test-csrf-token')
78
78
  stub_request(:post, 'http://example.org/durables/place').to_return(status: 500)
79
79
  Dir.mktmpdir do |d|
80
80
  file = File.join(d, 'test.txt')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: judges
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.47.0
4
+ version: 0.49.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko