-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
Signed-off-by: Kostiantyn Kostiuk <[email protected]>
- Loading branch information
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 | ||
Check notice Code scanning / Rubocop Use consistent metadata style. Note test
RSpec/MetadataStyle: Use symbol style for metadata.
|
||
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 |