Description:
more test on submission viewing
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r764:c7de60f1126a - - 4 files changed: 108 inserted, 9 deleted

@@ -1,10 +1,11
1 - %h2 Live submit
2 - %br
3 -
4 1 %textarea#text_sourcecode{style: "display:none"}~ @source
5 2 .container
6 3 .row
7 4 .col-md-12
5 + %h2 Live submit
6 +
7 + .row
8 + .col-md-12
8 9 .alert.alert-info
9 10 Write your code in the following box, choose language, and click submit button when finished
10 11 .row
@@ -1,24 +1,26
1 1 # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
2 2 prob_add:
3 - id: 1
4 3 name: add
5 4 full_name: add_full_name
5 + full_score: 100
6 6 available: true
7 7
8 8 prob_sub:
9 - id: 2
10 9 name: subtract
11 10 full_name: subtract_full_name
11 + full_score: 100
12 12 available: false
13 13
14 14 easy:
15 15 name: easy_problem
16 16 full_name: Easy Problem
17 17 available: true
18 + full_score: 10
18 19 contests: contest_a, contest_b
19 20
20 21 hard:
21 22 name: hard_problem
22 23 full_name: Hard Problem
23 24 available: true
25 + full_score: 20
24 26 contests: contest_b
@@ -1,10 +1,11
1 1 # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
2 2 add1_by_admin:
3 - id: 1
4 3 user: admin
5 4 problem: prob_add
6 5 language: Language_c
6 + submitted_at: "2019-10-22 08:34"
7 7 source:
8 + xxx
8 9 \#include <stdio>
9 10 \#include <stdlib>
10 11 int main() {
@@ -12,10 +13,10
12 13 }
13 14
14 15 sub1_by_admin:
15 - id: 2
16 16 user: admin
17 17 problem: prob_sub
18 18 language: Language_c
19 + submitted_at: "2019-10-22 08:34"
19 20 source:
20 21 \#include <stdio>
21 22 \#include <stdlib>
@@ -24,10 +25,22
24 25 }
25 26
26 27 add1_by_john:
27 - id: 3
28 28 user: john
29 29 problem: prob_add
30 30 language: Language_c
31 + submitted_at: "2019-10-22 08:34"
32 + source:
33 + \#include <stdio>
34 + \#include <stdlib>
35 + int main() {
36 + cout << 33 << endl;
37 + }
38 +
39 + add1_by_james:
40 + user: james
41 + problem: prob_add
42 + language: Language_c
43 + submitted_at: "2019-10-22 08:34"
31 44 source:
32 45 \#include <stdio>
33 46 \#include <stdlib>
@@ -36,10 +49,10
36 49 }
37 50
38 51 sub1_by_james:
39 - id: 4
40 52 user: james
41 53 problem: prob_sub
42 54 language: Language_c
55 + submitted_at: "2019-10-22 08:34"
43 56 source:
44 57 \#include <stdio>
45 58 \#include <stdlib>
@@ -34,6 +34,89
34 34 assert_text 'You are not authorized'
35 35 end
36 36
37 + test "admin view submissions" do
38 + login('admin','admin')
39 +
40 + #view own submission
41 + within 'header' do
42 + click_on 'Submission'
43 + click_on 'View'
44 + end
45 + click_on 'Go'
46 +
47 + #click the first <a> item in the table
48 + first('table a').click
49 + assert_text "Source Code"
50 + assert_text "Task"
51 +
52 + #view other submission of available problem
53 + within 'header' do
54 + click_on 'Manage'
55 + click_on 'Problem'
56 + end
57 +
58 + row = find('tr', text: 'add_full_name')
59 + within row do
60 + click_on 'Stat'
61 + end
62 +
63 + assert_text "Submissions"
64 + within find('tr', text: 'john') do
65 + first('a').click
66 + end
67 + assert_text "Source Code"
68 + assert_text "Task"
69 +
70 + #view other submission of unavailable problem
71 + visit submission_path( submissions(:sub1_by_james) )
72 + assert_text "Source Code"
73 + assert_text "Task"
74 + end
75 +
76 + test "user view submissions" do
77 + login('john','hello')
78 +
79 + #view own submission
80 + within 'header' do
81 + click_on 'Submission'
82 + click_on 'View'
83 + end
84 + click_on 'Go'
85 +
86 + #click the first <a> item in the table
87 + first('table a').click
88 + assert_text "Source Code"
89 + assert_text "Task"
90 +
91 + #view other submission of available problem
92 + GraderConfiguration.where(key: 'right.user_view_submission').update(value: 'true')
93 +
94 + #using direct link
95 + visit submission_path( submissions(:add1_by_james) )
96 + assert_text "Source Code"
97 + assert_text "Task"
98 +
99 + #view admin's submission of available problem
100 + #using direct link
101 + visit submission_path( submissions(:add1_by_admin) )
102 + assert_text "Source Code"
103 + assert_text "Task"
104 +
105 + #view other submission of unavailable problem
106 + visit submission_path( submissions(:sub1_by_james) )
107 + assert_text "You are not authorized"
108 +
109 + #view admin's submission of unavailable problem
110 + login('john','hello')
111 + visit submission_path( submissions(:sub1_by_admin) )
112 + assert_text "You are not authorized"
113 +
114 + #view other submission of available problem, right not allow
115 + GraderConfiguration.where(key: 'right.user_view_submission').update(value: 'false')
116 + login('john','hello')
117 + visit submission_path( submissions(:add1_by_james) )
118 + assert_text "You are not authorized"
119 + end
37 120
38 121 def login(username,password)
39 122 visit root_path
You need to be logged in to leave comments. Login now