-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: Upload test #275
base: main
Are you sure you want to change the base?
WIP: Upload test #275
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
FactoryBot.define do | ||
factory :task do | ||
display_name { '1st USA olympiad task number 1' } | ||
file_names { ['task1.md'] } | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe 'Upload', ui: true do | ||
let(:upload_path) { "/contests/#{contest.id}/upload/new" } | ||
let(:file_path) { "/contests/#{contest.id}/upload" } | ||
|
||
let(:contest) { create(:contest) } | ||
Check notice Code scanning / Rubocop Use parentheses for method calls with arguments. Note test
Style/MethodCallWithArgsParentheses: Omit parentheses for method calls with arguments.
|
||
let!(:task) { create(:task, contest:) } | ||
Check notice Code scanning / Rubocop Use parentheses for method calls with arguments. Note test
Style/MethodCallWithArgsParentheses: Omit parentheses for method calls with arguments.
|
||
let(:user) { create(:user, contest:) } | ||
Check notice Code scanning / Rubocop Use parentheses for method calls with arguments. Note test
Style/MethodCallWithArgsParentheses: Omit parentheses for method calls with arguments.
|
||
|
||
before { visit upload_path } | ||
|
||
describe 'solution for task' do | ||
before do | ||
fill_inputs 'upload', user.slice(:secret) | ||
click_button 'commit' | ||
end | ||
|
||
context 'with valid file' do | ||
before do | ||
# TODO: FIX upload[solutions_attributes][0][file] | ||
attach_file 'upload[solutions_attributes][0][file]', 'spec/support/fixtures/tasks_solutions/task1_ok/task1.md' | ||
click_button 'commit' | ||
end | ||
|
||
it { expect(page).to have_content "#{task.display_name}: успішно завантажений на сервер" } | ||
end | ||
|
||
context 'with empty file' do | ||
before do | ||
# TODO: FIX upload[solutions_attributes][0][file] | ||
attach_file 'upload[solutions_attributes][0][file]', 'spec/support/fixtures/tasks_solutions/task1_empty/task1.md' | ||
click_button 'commit' | ||
end | ||
|
||
it { | ||
expect(page).to have_content \ | ||
"#{task.display_name}: Помилка! Файл не може бути порожнім (0 байт). Можливо, файл відкрито у програмі MS Office." | ||
} | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Some task solution |
Check notice
Code scanning / Rubocop
Use consistent metadata style. Note test