From 5411be67506cb89f17b07e81e85a8f2fc89fec63 Mon Sep 17 00:00:00 2001 From: Anton Khorev Date: Mon, 8 Jan 2024 14:59:06 +0300 Subject: [PATCH] Test changeset commenting --- .../user_changeset_comments_test.rb | 35 ------------------- test/system/changeset_comments_test.rb | 22 ++++++++++++ 2 files changed, 22 insertions(+), 35 deletions(-) delete mode 100644 test/integration/user_changeset_comments_test.rb diff --git a/test/integration/user_changeset_comments_test.rb b/test/integration/user_changeset_comments_test.rb deleted file mode 100644 index a1f08ae6d..000000000 --- a/test/integration/user_changeset_comments_test.rb +++ /dev/null @@ -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 diff --git a/test/system/changeset_comments_test.rb b/test/system/changeset_comments_test.rb index beed3238c..51695c516 100644 --- a/test/system/changeset_comments_test.rb +++ b/test/system/changeset_comments_test.rb @@ -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 -- 2.39.5