-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4485 from dodona-edu/enhance/preload-last-submission
Preload the latest submission in the editor on the activity show page
- Loading branch information
Showing
7 changed files
with
103 additions
and
4 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
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 |
---|---|---|
|
@@ -186,6 +186,12 @@ center img { | |
} | ||
} | ||
|
||
#restore-boilerplate { | ||
a { | ||
cursor: pointer; | ||
} | ||
} | ||
|
||
pre { | ||
position: relative; | ||
|
||
|
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
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
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
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
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,60 @@ | ||
require 'capybara/minitest' | ||
require 'application_system_test_case' | ||
|
||
class ActivitiesTest < ApplicationSystemTestCase | ||
include Devise::Test::IntegrationHelpers | ||
# Make the Capybara DSL available in all integration tests | ||
include Capybara::DSL | ||
# Make `assert_*` methods behave like Minitest assertions | ||
include Capybara::Minitest::Assertions | ||
|
||
setup do | ||
@instance = exercises(:python_exercise) | ||
@user = users(:zeus) | ||
sign_in @user | ||
end | ||
|
||
test 'should show exercise' do | ||
visit exercise_path(id: @instance.id) | ||
assert_text @instance.name_en | ||
end | ||
|
||
test 'should show boilerplate in code editor' do | ||
@instance.stubs(:boilerplate).returns('boilerplate') do | ||
visit exercise_path(id: @instance.id) | ||
assert_text 'boilerplate' | ||
end | ||
end | ||
|
||
test 'show latest submission in code editor' do | ||
create(:submission, exercise: @instance, user: @user, status: :correct, code: 'print("hello")') | ||
visit exercise_path(id: @instance.id) | ||
assert_text 'print("hello")' | ||
end | ||
|
||
test 'should show message to clear editor if latest submission is shown' do | ||
create(:submission, exercise: @instance, user: @user, status: :correct, code: 'print("hello")') | ||
visit exercise_path(id: @instance.id) | ||
assert_text 'Clear editor' | ||
end | ||
|
||
test 'should show message to restore boilerplate if latest submission is shown' do | ||
@instance.stubs(:boilerplate).returns('boilerplate') do | ||
create(:submission, exercise: @instance, user: @user, status: :correct, code: 'print("hello")') | ||
visit exercise_path(id: @instance.id) | ||
assert_text 'Restore boilerplate' | ||
end | ||
end | ||
|
||
test 'should not break on complex unicode characters' do | ||
@instance.stubs(:boilerplate).returns('`<script>alert("π")</script>`') do | ||
visit exercise_path(id: @instance.id) | ||
assert_text '`<script>alert("π")</script>`' | ||
|
||
create(:submission, exercise: @instance, user: @user, status: :correct, code: 'print("π")') | ||
visit exercise_path(id: @instance.id) | ||
assert_text 'print("π")' | ||
assert_text 'Restore boilerplate' | ||
end | ||
end | ||
end |