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,13 +1,14
1 - %h2 Live submit
2 - %br
3 -
4 %textarea#text_sourcecode{style: "display:none"}~ @source
1 %textarea#text_sourcecode{style: "display:none"}~ @source
5 .container
2 .container
6 .row
3 .row
7 .col-md-12
4 .col-md-12
5 + %h2 Live submit
6 +
7 + .row
8 + .col-md-12
8 .alert.alert-info
9 .alert.alert-info
9 Write your code in the following box, choose language, and click submit button when finished
10 Write your code in the following box, choose language, and click submit button when finished
10 .row
11 .row
11 .col-md-8
12 .col-md-8
12 %div#editor{style: 'height: 500px; border-radius: 7px; font-size: 14px;'}
13 %div#editor{style: 'height: 500px; border-radius: 7px; font-size: 14px;'}
13 .col-md-4
14 .col-md-4
@@ -1,24 +1,26
1 # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
1 # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
2 prob_add:
2 prob_add:
3 - id: 1
4 name: add
3 name: add
5 full_name: add_full_name
4 full_name: add_full_name
5 + full_score: 100
6 available: true
6 available: true
7
7
8 prob_sub:
8 prob_sub:
9 - id: 2
10 name: subtract
9 name: subtract
11 full_name: subtract_full_name
10 full_name: subtract_full_name
11 + full_score: 100
12 available: false
12 available: false
13
13
14 easy:
14 easy:
15 name: easy_problem
15 name: easy_problem
16 full_name: Easy Problem
16 full_name: Easy Problem
17 available: true
17 available: true
18 + full_score: 10
18 contests: contest_a, contest_b
19 contests: contest_a, contest_b
19
20
20 hard:
21 hard:
21 name: hard_problem
22 name: hard_problem
22 full_name: Hard Problem
23 full_name: Hard Problem
23 available: true
24 available: true
25 + full_score: 20
24 contests: contest_b
26 contests: contest_b
@@ -1,48 +1,61
1 # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
1 # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
2 add1_by_admin:
2 add1_by_admin:
3 - id: 1
4 user: admin
3 user: admin
5 problem: prob_add
4 problem: prob_add
6 language: Language_c
5 language: Language_c
6 + submitted_at: "2019-10-22 08:34"
7 source:
7 source:
8 + xxx
8 \#include <stdio>
9 \#include <stdio>
9 \#include <stdlib>
10 \#include <stdlib>
10 int main() {
11 int main() {
11 cout << 1 << endl;
12 cout << 1 << endl;
12 }
13 }
13
14
14 sub1_by_admin:
15 sub1_by_admin:
15 - id: 2
16 user: admin
16 user: admin
17 problem: prob_sub
17 problem: prob_sub
18 language: Language_c
18 language: Language_c
19 + submitted_at: "2019-10-22 08:34"
19 source:
20 source:
20 \#include <stdio>
21 \#include <stdio>
21 \#include <stdlib>
22 \#include <stdlib>
22 int main() {
23 int main() {
23 cout << 2 << endl;
24 cout << 2 << endl;
24 }
25 }
25
26
26 add1_by_john:
27 add1_by_john:
27 - id: 3
28 user: john
28 user: john
29 problem: prob_add
29 problem: prob_add
30 language: Language_c
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 source:
44 source:
32 \#include <stdio>
45 \#include <stdio>
33 \#include <stdlib>
46 \#include <stdlib>
34 int main() {
47 int main() {
35 cout << 33 << endl;
48 cout << 33 << endl;
36 }
49 }
37
50
38 sub1_by_james:
51 sub1_by_james:
39 - id: 4
40 user: james
52 user: james
41 problem: prob_sub
53 problem: prob_sub
42 language: Language_c
54 language: Language_c
55 + submitted_at: "2019-10-22 08:34"
43 source:
56 source:
44 \#include <stdio>
57 \#include <stdio>
45 \#include <stdlib>
58 \#include <stdlib>
46 int main() {
59 int main() {
47 cout << 44 << endl;
60 cout << 44 << endl;
48 }
61 }
@@ -31,12 +31,95
31 #but not unavailable problem
31 #but not unavailable problem
32 login('john','hello')
32 login('john','hello')
33 visit direct_edit_problem_submissions_path(problems(:prob_sub))
33 visit direct_edit_problem_submissions_path(problems(:prob_sub))
34 assert_text 'You are not authorized'
34 assert_text 'You are not authorized'
35 end
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 def login(username,password)
121 def login(username,password)
39 visit root_path
122 visit root_path
40 fill_in "Login", with: username
123 fill_in "Login", with: username
41 fill_in "Password", with: password
124 fill_in "Password", with: password
42 click_on "Login"
125 click_on "Login"
You need to be logged in to leave comments. Login now