-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Kostiantyn Kostiuk <[email protected]>
- Loading branch information
1 parent
c44fb2f
commit 6223877
Showing
4 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) } | ||
let!(:task) { create(:task, contest:) } | ||
let(:user) { create(:user, contest:) } | ||
|
||
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 |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Some task solution |