From 793eaf4429999e214540746a4b36008b3d79797f Mon Sep 17 00:00:00 2001 From: taitus Date: Thu, 21 Dec 2023 14:00:22 +0100 Subject: [PATCH] Remove unnecessary specs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The test "display administrator id on public views" is not correct. The valuation comments are not display never on public views. If we reload this admin page we can see that the description is render instead of administrator_id as we can see at the upper test: ``` scenario "display administrator description on admin views" ``` The deleted test was passed because there is an error at the moment to render the comments. As we can see in the file ´app/views/comments/create.js.erb:10´ we try render comment without valuation value: ``` App.Comments.add_comment(parent_id, "
  • <%= j(render @comment) %>
  • "); ``` That it is necessary to render correctly the description or the id. By other hand the test "public users not see admin description" is already being checked in the 'system/comments_specs'. However, we are going to add a new expectation to make sure that the admin description does not appear on the public pages. --- .../comments/budget_investments_spec.rb | 38 +------------------ spec/system/comments_spec.rb | 3 +- 2 files changed, 3 insertions(+), 38 deletions(-) diff --git a/spec/system/comments/budget_investments_spec.rb b/spec/system/comments/budget_investments_spec.rb index 526bc2fe5..a998f736f 100644 --- a/spec/system/comments/budget_investments_spec.rb +++ b/spec/system/comments/budget_investments_spec.rb @@ -20,7 +20,7 @@ describe "Commenting Budget::Investments" do expect(page).to have_content "I am your Admin!" end - visit admin_budget_budget_investment_path(investment.budget, investment) + refresh within "#comments" do expect(page).to have_content "I am your Admin!" @@ -29,42 +29,6 @@ describe "Commenting Budget::Investments" do expect(page).to have_css "img.admin-avatar" end end - - scenario "display administrator id on public views" do - admin = create(:administrator, description: "user description") - - login_as(admin.user) - visit admin_budget_budget_investment_path(investment.budget, investment) - - fill_in "Leave your comment", with: "I am your Admin!" - check "comment-as-administrator-budget_investment_#{investment.id}" - click_button "Publish comment" - - within "#comments" do - expect(page).to have_content "I am your Admin!" - expect(page).to have_content "Administrator ##{admin.id}" - expect(page).to have_css "div.is-admin" - expect(page).to have_css "img.admin-avatar" - end - end - - scenario "public users not see admin description" do - manuela = create(:user, username: "Manuela") - admin = create(:administrator, user: manuela) - comment = create(:comment, - commentable: investment, - user: manuela, - administrator_id: admin.id) - - visit budget_investment_path(investment.budget, investment) - - within "#comment_#{comment.id}" do - expect(page).to have_content comment.body - expect(page).to have_content "Administrator ##{admin.id}" - expect(page).to have_css "img.admin-avatar" - expect(page).to have_css "div.is-admin" - end - end end end end diff --git a/spec/system/comments_spec.rb b/spec/system/comments_spec.rb index bf8ced835..c8a33de68 100644 --- a/spec/system/comments_spec.rb +++ b/spec/system/comments_spec.rb @@ -570,7 +570,7 @@ describe "Comments" do describe "Administrators" do scenario "can create comment" do - admin = create(:administrator) + admin = create(:administrator, description: "admin user") login_as(admin.user) visit polymorphic_path(resource) @@ -584,6 +584,7 @@ describe "Comments" do within "#comments" do expect(page).to have_content "I am your Admin!" expect(page).to have_content "Administrator ##{admin.id}" + expect(page).not_to have_content "Administrator admin user" expect(page).to have_css "div.is-admin" expect(page).to have_css "img.admin-avatar" end