Skip to content

Commit

Permalink
Fix specs and missing features
Browse files Browse the repository at this point in the history
  • Loading branch information
rhian-cs committed Dec 15, 2021
1 parent 1d49c98 commit ebf038f
Show file tree
Hide file tree
Showing 49 changed files with 139 additions and 112 deletions.
6 changes: 3 additions & 3 deletions app/components/moderation/shared/index_component.html.erb
Expand Up @@ -21,18 +21,18 @@
<%= submit_tag t("moderation.#{i18n_namespace}.index.block_authors"),
name: "block_authors",
class: "button hollow alert",
data: { confirm: t("moderation.#{i18n_namespace}.index.confirm") } %>
data: { confirm: t("moderation.#{i18n_namespace}.index.confirm_action", action: t("moderation.#{i18n_namespace}.index.block_authors")) } %>

<div class="float-right">
<%= submit_tag t("moderation.#{i18n_namespace}.index.hide"),
name: "hide_#{table_name}",
class: "button hollow alert",
data: { confirm: t("moderation.#{i18n_namespace}.index.confirm") } %>
data: { confirm: t("moderation.#{i18n_namespace}.index.confirm_action", action: t("moderation.#{i18n_namespace}.index.hide")) } %>
<%= submit_tag t("moderation.#{i18n_namespace}.index.ignore_flags"),
name: "ignore_flags",
class: "button hollow",
data: { confirm: t("moderation.#{i18n_namespace}.index.confirm") } %>
data: { confirm: t("moderation.#{i18n_namespace}.index.confirm_action", action: t("moderation.#{i18n_namespace}.index.ignore_flags")) } %>
</div>

<%= paginate records %>
Expand Down
Expand Up @@ -18,6 +18,6 @@
class: "delete float-right",
method: :delete,
remote: true,
data: { confirm: t("admin.actions.confirm_action", action: t("images.remove_image")) } %>
data: { confirm: t("admin.actions.confirm_action", action: t("images.remove_image"), name: image.title) } %>
</div>
<% end %>
4 changes: 2 additions & 2 deletions app/views/budgets/investments/_actions.html.erb
@@ -1,10 +1,10 @@
<% if can? :hide, investment %>
<%= link_to t("admin.actions.hide").capitalize, hide_moderation_budget_investment_path(investment),
method: :put, remote: true, data: { confirm: t("admin.actions.confirm_action", action: t("admin.actions.hide")) } %>
method: :put, remote: true, data: { confirm: t("admin.actions.confirm_action", action: t("admin.actions.hide"), name: investment.title) } %>
<% end %>
<% if can? :hide, investment.author %>
&nbsp;|&nbsp;
<%= link_to t("admin.actions.hide_author").capitalize, hide_moderation_user_path(investment.author_id),
method: :put, data: { confirm: t("admin.actions.confirm_action", action: t("admin.actions.hide_author")) } %>
method: :put, data: { confirm: t("admin.actions.confirm_action", action: t("admin.actions.hide_author"), name: investment.author.name) } %>
<% end %>
4 changes: 2 additions & 2 deletions app/views/comments/_actions.html.erb
Expand Up @@ -12,13 +12,13 @@
data: { confirm: t("comments.actions.confirm_delete") } %>
<% else %>
<%= link_to t("admin.actions.hide").capitalize, hide_moderation_comment_path(comment),
method: :put, remote: true, data: { confirm: t("admin.actions.confirm_action", action: t("admin.actions.hide")) } %>
method: :put, remote: true, data: { confirm: t("admin.actions.confirm_action", action: t("admin.actions.hide"), name: comment.body.truncate(32)) } %>
<% end %>
<% end %>
<% if can? :hide, comment.user %>
<span class="divider">&nbsp;&bull;&nbsp;</span>
<%= link_to t("admin.actions.hide_author").capitalize, hide_moderation_user_path(comment.user_id),
method: :put, data: { confirm: t("admin.actions.confirm_action", action: t("admin.actions.hide_author")) } %>
method: :put, data: { confirm: t("admin.actions.confirm_action", action: t("admin.actions.hide_author"), name: comment.author.name) } %>
<% end %>
</span>
8 changes: 4 additions & 4 deletions app/views/debates/_actions.html.erb
@@ -1,21 +1,21 @@
<% if can? :hide, debate %>
<%= link_to t("admin.actions.hide").capitalize, hide_moderation_debate_path(debate),
method: :put, remote: true, data: { confirm: t("admin.actions.confirm_action", action: t("admin.actions.hide")) } %>
method: :put, remote: true, data: { confirm: t("admin.actions.confirm_action", action: t("admin.actions.hide"), name: debate.title) } %>
<% end %>
<% if can? :hide, debate.author %>
&nbsp;|&nbsp;
<%= link_to t("admin.actions.hide_author").capitalize, hide_moderation_user_path(debate.author_id),
method: :put, data: { confirm: t("admin.actions.confirm_action", action: t("admin.actions.hide_author")) } %>
method: :put, data: { confirm: t("admin.actions.confirm_action", action: t("admin.actions.hide_author"), name: debate.author.name) } %>
<% end %>
<% if can? :mark_featured, debate %>
&nbsp;|&nbsp;
<% if debate.featured? %>
<%= link_to t("admin.actions.unmark_featured").capitalize, unmark_featured_debate_path(debate),
method: :put, data: { confirm: t("admin.actions.confirm_action", action: t("admin.actions.unmark_featured")) } %>
method: :put, data: { confirm: t("admin.actions.confirm_action", action: t("admin.actions.unmark_featured"), name: debate.title) } %>
<% else %>
<%= link_to t("admin.actions.mark_featured").capitalize, mark_featured_debate_path(debate),
method: :put, data: { confirm: t("admin.actions.confirm_action", action: t("admin.actions.mark_featured")) } %>
method: :put, data: { confirm: t("admin.actions.confirm_action", action: t("admin.actions.mark_featured"), name: debate.title) } %>
<% end %>
<% end %>
4 changes: 2 additions & 2 deletions app/views/legislation/proposals/_actions.html.erb
@@ -1,10 +1,10 @@
<% if can? :hide, proposal %>
<%= link_to t("admin.actions.hide").capitalize, hide_moderation_legislation_proposal_path(proposal),
method: :put, remote: true, data: { confirm: t("admin.actions.confirm_action", action: t("admin.actions.hide")) } %>
method: :put, remote: true, data: { confirm: t("admin.actions.confirm_action", action: t("admin.actions.hide"), name: proposal.title) } %>
<% end %>
<% if can? :hide, proposal.author %>
&nbsp;|&nbsp;
<%= link_to t("admin.actions.hide_author").capitalize, hide_moderation_user_path(proposal.author_id),
method: :put, data: { confirm: t("admin.actions.confirm_action", action: t("admin.actions.hide_author")) } %>
method: :put, data: { confirm: t("admin.actions.confirm_action", action: t("admin.actions.hide_author"), name: proposal.author.name) } %>
<% end %>
4 changes: 2 additions & 2 deletions app/views/proposal_notifications/_actions.html.erb
Expand Up @@ -3,13 +3,13 @@
<span class="js-moderation-actions">
<% if can? :hide, notification %>
<%= link_to t("admin.actions.hide").capitalize, hide_moderation_proposal_notification_path(notification),
method: :put, remote: true, data: { confirm: t("admin.actions.confirm_action", action: t("admin.actions.hide")) } %>
method: :put, remote: true, data: { confirm: t("admin.actions.confirm_action", action: t("admin.actions.hide"), name: notification.notifiable_title) } %>
<% end %>
<% if can? :hide, notification.author %>
<span class="divider">&nbsp;&bull;&nbsp;</span>
<%= link_to t("admin.actions.hide_author").capitalize, hide_moderation_user_path(notification.author_id),
method: :put, data: { confirm: t("admin.actions.confirm_action", action: t("admin.actions.hide_author")) } %>
method: :put, data: { confirm: t("admin.actions.confirm_action", action: t("admin.actions.hide_author"), name: notification.author.name) } %>
<% end %>
</span>
</div>
Expand Down
4 changes: 2 additions & 2 deletions app/views/proposals/_actions.html.erb
@@ -1,10 +1,10 @@
<% if can? :hide, proposal %>
<%= link_to t("admin.actions.hide").capitalize, hide_moderation_proposal_path(proposal),
method: :put, remote: true, data: { confirm: t("admin.actions.confirm_action", action: t("admin.actions.hide")) } %>
method: :put, remote: true, data: { confirm: t("admin.actions.confirm_action", action: t("admin.actions.hide"), name: proposal.title) } %>
<% end %>
<% if can? :hide, proposal.author %>
&nbsp;|&nbsp;
<%= link_to t("admin.actions.hide_author").capitalize, hide_moderation_user_path(proposal.author_id),
method: :put, data: { confirm: t("admin.actions.confirm_action", action: t("admin.actions.hide_author")) } %>
method: :put, data: { confirm: t("admin.actions.confirm_action", action: t("admin.actions.hide_author"), name: proposal.author.name) } %>
<% end %>
5 changes: 5 additions & 0 deletions config/locales/en/moderation.yml
Expand Up @@ -3,6 +3,7 @@ en:
comments:
index:
block_authors: Block authors
confirm_action: "Are you sure? %{action}"
filter: Filter
filters:
all: All
Expand All @@ -23,6 +24,7 @@ en:
debates:
index:
block_authors: Block authors
confirm_action: "Are you sure? %{action}"
filter: Filter
filters:
all: All
Expand All @@ -49,6 +51,7 @@ en:
proposals:
index:
block_authors: Block authors
confirm_action: "Are you sure? %{action}"
filter: Filter
filters:
all: All
Expand All @@ -66,6 +69,7 @@ en:
budget_investments:
index:
block_authors: Block authors
confirm_action: "Are you sure? %{action}"
filter: Filter
filters:
all: All
Expand All @@ -83,6 +87,7 @@ en:
proposal_notifications:
index:
block_authors: Block authors
confirm_action: "Are you sure? %{action}"
filter: Filter
filters:
all: All
Expand Down
28 changes: 14 additions & 14 deletions spec/system/admin/activity_spec.rb
Expand Up @@ -14,7 +14,7 @@
visit proposal_path(proposal)

within("#proposal_#{proposal.id}") do
accept_confirm("Hide: Are you sure?") { click_link "Hide" }
accept_confirm("Are you sure? Hide \"#{proposal.title}\"") { click_link "Hide" }
end
expect(page).to have_css("#proposal_#{proposal.id}.faded")

Expand Down Expand Up @@ -43,7 +43,7 @@
check "proposal_#{proposal3.id}_check"
end

accept_confirm("Hide proposals: Are you sure?") { click_button "Hide proposals" }
accept_confirm("Are you sure? Hide proposals") { click_button "Hide proposals" }

expect(page).not_to have_content(proposal1.title)

Expand All @@ -60,7 +60,7 @@
visit admin_hidden_proposals_path

within("#proposal_#{proposal.id}") do
accept_confirm("Restore: Are you sure?") { click_link "Restore" }
accept_confirm("Are you sure? Restore") { click_button "Restore" }
end

expect(page).to have_content "There are no hidden proposals"
Expand All @@ -82,7 +82,7 @@
visit debate_path(debate)

within("#debate_#{debate.id}") do
accept_confirm("Hide: Are you sure?") { click_link "Hide" }
accept_confirm("Are you sure? Hide \"#{debate.title}\"") { click_link "Hide" }
end
expect(page).to have_css("#debate_#{debate.id}.faded")

Expand Down Expand Up @@ -110,7 +110,7 @@
check "debate_#{debate3.id}_check"
end

accept_confirm("Hide debates: Are you sure?") { click_button "Hide debates" }
accept_confirm("Are you sure? Hide debates") { click_button "Hide debates" }

expect(page).not_to have_content(debate1.title)

Expand All @@ -127,7 +127,7 @@
visit admin_hidden_debates_path

within("#debate_#{debate.id}") do
accept_confirm("Restore: Are you sure?") { click_link "Restore" }
accept_confirm("Are you sure? Restore") { click_button "Restore" }
end

expect(page).to have_content "There are no hidden debates"
Expand All @@ -150,7 +150,7 @@
visit debate_path(debate)

within("#comment_#{comment.id}") do
accept_confirm("Hide: Are you sure?") { click_link "Hide" }
accept_confirm("Are you sure? Hide \"#{comment.body}\"") { click_link "Hide" }
expect(page).to have_css(".faded")
end

Expand Down Expand Up @@ -178,7 +178,7 @@
check "comment_#{comment3.id}_check"
end

accept_confirm("Hide comments: Are you sure?") { click_button "Hide comments" }
accept_confirm("Are you sure? Hide comments") { click_button "Hide comments" }

expect(page).not_to have_content(comment1.body)

Expand All @@ -195,7 +195,7 @@
visit admin_hidden_comments_path

within("#comment_#{comment.id}") do
accept_confirm("Restore: Are you sure?") { click_link "Restore" }
accept_confirm("Are you sure? Restore") { click_button "Restore" }
end

expect(page).to have_content "There are no hidden comments"
Expand All @@ -217,7 +217,7 @@
visit proposal_path(proposal)

within("#proposal_#{proposal.id}") do
accept_confirm("Hide author: Are you sure?") { click_link "Hide author" }
accept_confirm("Are you sure? Hide author \"#{proposal.author.name}\"") { click_link "Hide author" }

expect(page).to have_current_path(debates_path)
end
Expand Down Expand Up @@ -266,7 +266,7 @@
check "proposal_#{proposal3.id}_check"
end

accept_confirm("Block authors: Are you sure?") { click_button "Block authors" }
accept_confirm("Are you sure? Block authors") { click_button "Block authors" }

expect(page).not_to have_content(proposal1.author.username)

Expand Down Expand Up @@ -294,7 +294,7 @@
check "debate_#{debate3.id}_check"
end

accept_confirm("Block authors: Are you sure?") { click_button "Block authors" }
accept_confirm("Are you sure? Block authors") { click_button "Block authors" }

expect(page).not_to have_content(debate1.author.username)

Expand Down Expand Up @@ -322,7 +322,7 @@
check "comment_#{comment3.id}_check"
end

accept_confirm("Block authors: Are you sure?") { click_button "Block authors" }
accept_confirm("Are you sure? Block authors") { click_button "Block authors" }

expect(page).not_to have_content comment1.author.username

Expand All @@ -341,7 +341,7 @@
visit admin_hidden_users_path

within("#user_#{user.id}") do
accept_confirm("Restore: Are you sure?") { click_link "Restore" }
accept_confirm("Are you sure? Restore") { click_button "Restore" }
end

expect(page).to have_content "There are no hidden users"
Expand Down
2 changes: 1 addition & 1 deletion spec/system/admin/admin_notifications_spec.rb
Expand Up @@ -118,7 +118,7 @@

visit admin_admin_notifications_path
within("#admin_notification_#{notification.id}") do
accept_confirm("Delete: Are you sure?") { click_link "Delete" }
accept_confirm("Are you sure? This action will delete \"#{notification.title}\" and can't be undone.") { click_button "Delete" }
end

expect(page).to have_content "Notification deleted successfully"
Expand Down
6 changes: 3 additions & 3 deletions spec/system/admin/administrators_spec.rb
Expand Up @@ -36,7 +36,7 @@
visit admin_administrators_path

within "#administrator_#{user_administrator.id}" do
accept_confirm("Delete: Are you sure?") { click_link "Delete" }
accept_confirm("Are you sure? This action will delete \"#{user_administrator.name}\" and can't be undone.") { click_button "Delete" }
end

within("#administrators") do
Expand All @@ -48,7 +48,7 @@
visit admin_administrators_path

within "#administrator_#{admin.id}" do
accept_confirm("Delete: Are you sure?") { click_link "Delete" }
accept_confirm("Are you sure? This action will delete \"#{admin.name}\" and can't be undone.") { click_button "Delete" }
end

within("#error") do
Expand Down Expand Up @@ -112,7 +112,7 @@
fill_in "Search user by name or email", with: administrator2.email
click_button "Search"

accept_confirm("Delete: Are you sure?") { click_link "Delete" }
accept_confirm("Are you sure? This action will delete \"#{administrator2.name}\" and can't be undone.") { click_button "Delete" }

expect(page).to have_content(administrator1.email)
expect(page).not_to have_content(administrator2.email)
Expand Down
6 changes: 4 additions & 2 deletions spec/system/admin/banners_spec.rb
Expand Up @@ -161,7 +161,7 @@
end

scenario "Delete a banner" do
create(:banner, title: "Ugly banner",
banner = create(:banner, title: "Ugly banner",
description: "Bad text",
target_url: "http://www.url.com",
post_started_at: (Date.current + 4.days),
Expand All @@ -173,7 +173,9 @@

expect(page).to have_content "Ugly banner"

accept_confirm("Delete banner: Are you sure?") { click_link "Delete banner" }
accept_confirm("Are you sure? This action will delete \"#{banner.title}\" and can't be undone.") do
click_button "Delete"
end

visit admin_root_path
expect(page).not_to have_content "Ugly banner"
Expand Down
11 changes: 7 additions & 4 deletions spec/system/admin/budget_groups_spec.rb
Expand Up @@ -46,11 +46,13 @@
end

scenario "Delete a group without headings" do
create(:budget_group, budget: budget, name: "Nowhere")
group = create(:budget_group, budget: budget, name: "Nowhere")

visit admin_budget_path(budget)

accept_confirm("Delete Nowhere: Are you sure?") { click_button "Delete Nowhere" }
accept_confirm("Are you sure? This action will delete \"#{group.name}\" and can't be undone.") do
click_button "Delete #{group.name}"
end

expect(page).to have_content "Group deleted successfully"
expect(page).not_to have_content "Nowhere"
Expand All @@ -62,8 +64,9 @@

visit admin_budget_path(budget)

accept_confirm("Delete Everywhere: Are you sure?") { click_button "Delete Everywhere" }

accept_confirm("Are you sure? This action will delete \"#{group.name}\" and can't be undone.") do
click_button "Delete #{group.name}"
end
expect(page).to have_content "You cannot delete a Group that has associated headings"
expect(page).to have_content "Everywhere"
end
Expand Down
4 changes: 2 additions & 2 deletions spec/system/admin/budget_headings_spec.rb
Expand Up @@ -51,7 +51,7 @@

visit admin_budget_path(budget)

within("tr", text: "Lemuria") { accept_confirm("Delete: Are you sure?") { click_button "Delete" } }
within("tr", text: "Lemuria") { accept_confirm("Are you sure? This action will delete \"Lemuria\" and can't be undone.") { click_button "Delete" } }

expect(page).to have_content "Heading deleted successfully"
expect(page).not_to have_content "Lemuria"
Expand All @@ -62,7 +62,7 @@
create(:budget_investment, heading: heading)

visit admin_budget_path(budget)
within(".heading", text: "Atlantis") { accept_confirm("Delete: Are you sure?") { click_button "Delete" } }
within(".heading", text: "Atlantis") { accept_confirm("Are you sure? This action will delete \"Atlantis\" and can't be undone.") { click_button "Delete" } }

expect(page).to have_content "You cannot delete a Heading that has associated investments"
expect(page).to have_content "Atlantis"
Expand Down

0 comments on commit ebf038f

Please sign in to comment.