Test changeset commenting

This commit is contained in:
Anton Khorev 2024-01-08 14:59:06 +03:00
parent 61c32388a9
commit 5411be6750
2 changed files with 22 additions and 35 deletions

View file

@ -1,35 +0,0 @@
require "test_helper"
class UserChangesetCommentsTest < ActionDispatch::IntegrationTest
# Test if the form is shown
def test_displaying_form
user = create(:user)
changeset = create(:changeset, :closed)
get "/login"
follow_redirect!
# We should now be at the login page
assert_response :success
assert_template "sessions/new"
# We can now login
post "/login", :params => { "username" => user.email, "password" => "test" }
assert_response :redirect
get "/changeset/#{changeset.id}"
assert_response :success
assert_template "browse/changeset"
assert_select "div#content" do
assert_select "div#sidebar" do
assert_select "div#sidebar_content" do
assert_select "div" do
assert_select "form[action='#']" do
assert_select "textarea[name=text]"
end
end
end
end
end
end
end

View file

@ -22,4 +22,26 @@ class ChangesetCommentsTest < ApplicationSystemTestCase
assert_link "Log in to join the discussion", :href => login_path(:referer => changeset_path(changeset))
end
end
test "can add a comment to a changeset" do
changeset = create(:changeset, :closed)
user = create(:user)
sign_in_as(user)
visit changeset_path(changeset)
within_sidebar do
assert_no_content "Comment from #{user.display_name}"
assert_no_content "Some newly added changeset comment"
assert_button "Comment", :disabled => true
fill_in "text", :with => "Some newly added changeset comment"
assert_button "Comment", :disabled => false
click_on "Comment"
assert_content "Comment from #{user.display_name}"
assert_content "Some newly added changeset comment"
end
end
end