Use a button for non-GET table actions
Links acting like buttons have a few disadvantages.
First, screen readers will announce them as "links". Screen reader users
usually associate links with "things that get you somewhere" and buttons
with "things that perform an action". So when something like "Delete,
link" is announced, they'll probably think this is a link which will
take them to another page where they can delete a record.
Furthermore, the URL of the link for the "destroy" action might be the
same as the URL for the "show" action (only one is accessed with a
DELETE request and the other one with a GET request). That means screen
readers could announce the link like "Delete, visited link", which is
very confusing.
They also won't work when opening links in a new tab, since opening
links in a new tab always results in a GET request to the URL the link
points to.
Finally, submit buttons work without JavaScript enabled, so they'll work
even if the JavaScript in the page hasn't loaded (for whatever reason).
For all these reasons (and probably many more), using a button to send
forms is IMHO superior to using links.
There's one disadvantage, though. Using `button_to` we create a <form>
tag, which means we'll generate invalid HTML if the table is inside
another form. If we run into this issue, we need to use `button_tag`
with a `form` attribute and then generate a form somewhere else inside
the HTML (with `content_for`).
Note we're using `button_to` with a block so it generates a <button>
tag. Using it in a different way the text would result in an <input />
tag, and input elements can't have pseudocontent added via CSS.
The following code could be a starting point to use the `button_tag`
with a `form` attribute. One advantage of this approach is screen
readers wouldn't announce "leaving form" while navigating through these
buttons. However, it doesn't work in Internet Explorer.
```
ERB:
<% content_for(:hidden_content, form_tag(path, form_options) {}) %>
<%= button_tag text, button_options %>
Ruby:
def form_id
path.gsub("/", "_")
end
def form_options
{ id: form_id, method: options[:method] }
end
def button_options
html_options.except(:method).merge(form: form_id)
end
Layout:
<%= content_for :hidden_content %> # Right before the `</body>`
```
This commit is contained in:
@@ -5,7 +5,8 @@
|
||||
margin-left: rem-calc(10);
|
||||
}
|
||||
|
||||
a {
|
||||
a,
|
||||
button {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -25,6 +26,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
button {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.edit-link {
|
||||
@include has-fa-icon(edit, regular);
|
||||
}
|
||||
@@ -121,6 +126,7 @@
|
||||
.manage-link,
|
||||
.ballots-link {
|
||||
@include has-fa-icon(archive, solid);
|
||||
color: $link;
|
||||
}
|
||||
|
||||
.cards-link {
|
||||
|
||||
@@ -1 +1,5 @@
|
||||
<%= link_to text, path, html_options %>
|
||||
<% if options[:method] && options[:method] != :get %>
|
||||
<%= button_to(path, html_options) { text } %>
|
||||
<% else %>
|
||||
<%= link_to text, path, html_options %>
|
||||
<% end %>
|
||||
|
||||
@@ -4,22 +4,24 @@ describe Admin::Budgets::TableActionsComponent, controller: Admin::BaseControlle
|
||||
let(:budget) { create(:budget) }
|
||||
let(:component) { Admin::Budgets::TableActionsComponent.new(budget) }
|
||||
|
||||
it "renders links to edit and delete budget, manage investments and edit groups and manage ballots" do
|
||||
it "renders actions to edit and delete budget, manage investments and edit groups and manage ballots" do
|
||||
render_inline component
|
||||
|
||||
expect(page).to have_css "a", count: 6
|
||||
expect(page).to have_link count: 4
|
||||
expect(page).to have_link "Investment projects", href: /investments/
|
||||
expect(page).to have_link "Heading groups", href: /groups/
|
||||
expect(page).to have_link "Edit", href: /edit/
|
||||
expect(page).to have_link "Ballots"
|
||||
expect(page).to have_link "Preview", href: /budgets/
|
||||
expect(page).to have_link "Delete", href: /budgets/
|
||||
|
||||
expect(page).to have_button count: 2
|
||||
expect(page).to have_css "form[action*='budgets']", exact_text: "Delete"
|
||||
expect(page).to have_button "Ballots"
|
||||
end
|
||||
|
||||
it "renders link to create new poll for budgets without polls" do
|
||||
it "renders button to create new poll for budgets without polls" do
|
||||
render_inline component
|
||||
|
||||
expect(page).to have_css "a[href*='polls'][data-method='post']", text: "Ballots"
|
||||
expect(page).to have_css "form[action*='polls'][method='post']", exact_text: "Ballots"
|
||||
end
|
||||
|
||||
it "renders link to manage ballots for budgets with polls" do
|
||||
|
||||
@@ -4,11 +4,12 @@ describe Admin::HiddenTableActionsComponent do
|
||||
let(:record) { create(:user) }
|
||||
let(:component) { Admin::HiddenTableActionsComponent.new(record) }
|
||||
|
||||
it "renders links to restore and confirm hide" do
|
||||
it "renders buttons to restore and confirm hide" do
|
||||
render_inline component
|
||||
|
||||
expect(page).to have_css "a", count: 2
|
||||
expect(page).to have_css "a[href*='restore'][data-method='put']", text: "Restore"
|
||||
expect(page).to have_css "a[href*='confirm_hide'][data-method='put']", text: "Confirm moderation"
|
||||
expect(page).to have_button count: 2
|
||||
expect(page).to have_css "form[action*='restore']", exact_text: "Restore"
|
||||
expect(page).to have_css "form[action*='confirm_hide']", exact_text: "Confirm moderation"
|
||||
expect(page).to have_css "input[name='_method'][value='put']", visible: :hidden, count: 2
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,35 +4,36 @@ describe Admin::Organizations::TableActionsComponent, controller: Admin::Organiz
|
||||
let(:organization) { create(:organization) }
|
||||
let(:component) { Admin::Organizations::TableActionsComponent.new(organization) }
|
||||
|
||||
it "renders links to verify and reject when it can" do
|
||||
it "renders buttons to verify and reject when it can" do
|
||||
allow(component).to receive(:can_verify?).and_return(true)
|
||||
allow(component).to receive(:can_reject?).and_return(true)
|
||||
|
||||
render_inline component
|
||||
|
||||
expect(page).to have_css "a", count: 2
|
||||
expect(page).to have_css "a[href*='verify'][data-method='put']", text: "Verify"
|
||||
expect(page).to have_css "a[href*='reject'][data-method='put']", text: "Reject"
|
||||
expect(page).to have_button count: 2
|
||||
expect(page).to have_css "form[action*='verify']", exact_text: "Verify"
|
||||
expect(page).to have_css "form[action*='reject']", exact_text: "Reject"
|
||||
expect(page).to have_css "input[name='_method'][value='put']", visible: :hidden, count: 2
|
||||
end
|
||||
|
||||
it "renders link to verify when it cannot reject" do
|
||||
it "renders button to verify when it cannot reject" do
|
||||
allow(component).to receive(:can_verify?).and_return(true)
|
||||
allow(component).to receive(:can_reject?).and_return(false)
|
||||
|
||||
render_inline component
|
||||
|
||||
expect(page).to have_css "a", count: 1
|
||||
expect(page).to have_link "Verify"
|
||||
expect(page).to have_button count: 1
|
||||
expect(page).to have_button "Verify"
|
||||
end
|
||||
|
||||
it "renders link to reject when it cannot verify" do
|
||||
it "renders button to reject when it cannot verify" do
|
||||
allow(component).to receive(:can_verify?).and_return(false)
|
||||
allow(component).to receive(:can_reject?).and_return(true)
|
||||
|
||||
render_inline component
|
||||
|
||||
expect(page).to have_css "a", count: 1
|
||||
expect(page).to have_link "Reject"
|
||||
expect(page).to have_button count: 1
|
||||
expect(page).to have_button "Reject"
|
||||
end
|
||||
|
||||
it "does not render any actions when it cannot verify nor reject" do
|
||||
@@ -41,6 +42,6 @@ describe Admin::Organizations::TableActionsComponent, controller: Admin::Organiz
|
||||
|
||||
render_inline component
|
||||
|
||||
expect(page).not_to have_css "a"
|
||||
expect(page).not_to have_button
|
||||
end
|
||||
end
|
||||
|
||||
@@ -12,21 +12,24 @@ describe Admin::Poll::Officers::OfficersComponent, controller: Admin::BaseContro
|
||||
tbody = page.find("tbody")
|
||||
|
||||
expect(tbody).to have_css "tr", count: 2
|
||||
expect(tbody).to have_css "a", count: 2
|
||||
expect(tbody).to have_button count: 2
|
||||
end
|
||||
|
||||
it "renders link to destroy for existing officers" do
|
||||
it "renders button to destroy for existing officers" do
|
||||
render_inline component
|
||||
row = page.find("tr", text: "Old officer")
|
||||
|
||||
expect(row).to have_css "a[data-method='delete']", text: "Delete"
|
||||
expect(row).to have_button "Delete position"
|
||||
expect(row).to have_css "input[name='_method'][value='delete']", visible: :hidden
|
||||
end
|
||||
|
||||
it "renders link to add for new officers" do
|
||||
it "renders button to add for new officers" do
|
||||
render_inline component
|
||||
row = page.find("tr", text: "New officer")
|
||||
|
||||
expect(row).to have_css "a[data-method='post']", text: "Add"
|
||||
expect(row).to have_button "Add"
|
||||
expect(row).to have_css "form[method='post']"
|
||||
expect(row).not_to have_css "input[name='_method']", visible: :all
|
||||
end
|
||||
|
||||
it "accepts table options" do
|
||||
|
||||
@@ -3,15 +3,17 @@ require "rails_helper"
|
||||
describe Admin::Roles::TableActionsComponent, controller: Admin::BaseController do
|
||||
let(:user) { create(:user) }
|
||||
|
||||
it "renders link to add the role for new records" do
|
||||
it "renders button to add the role for new records" do
|
||||
render_inline Admin::Roles::TableActionsComponent.new(user.build_manager)
|
||||
|
||||
expect(page).to have_css "a[data-method='post']", text: "Add"
|
||||
expect(page).to have_css "form[method='post']", exact_text: "Add"
|
||||
expect(page).not_to have_css "input[name='_method']", visible: :all
|
||||
end
|
||||
|
||||
it "renders link to remove the role for existing records" do
|
||||
it "renders button to remove the role for existing records" do
|
||||
render_inline Admin::Roles::TableActionsComponent.new(create(:manager, user: user))
|
||||
|
||||
expect(page).to have_css "a[data-method='delete']", text: "Delete"
|
||||
expect(page).to have_css "form[method='post']", exact_text: "Delete"
|
||||
expect(page).to have_css "input[name='_method'][value='delete']", visible: :hidden
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,14 +3,16 @@ require "rails_helper"
|
||||
describe Admin::TableActionsComponent, controller: Admin::BaseController do
|
||||
let(:record) { create(:banner, title: "Important!") }
|
||||
|
||||
it "renders links to edit and destroy a record by default" do
|
||||
it "renders edit and destroy actions by default" do
|
||||
render_inline Admin::TableActionsComponent.new(record)
|
||||
|
||||
expect(page).to have_css "a", count: 2
|
||||
expect(page).to have_link count: 1
|
||||
expect(page).to have_css "a[href*='edit']", exact_text: "Edit"
|
||||
expect(page).to have_css "a[aria-label='Edit Important!']", exact_text: "Edit"
|
||||
expect(page).to have_css "a[data-method='delete']", exact_text: "Delete"
|
||||
expect(page).to have_css "a[aria-label='Delete Important!']", exact_text: "Delete"
|
||||
expect(page).to have_css "a[aria-label='Edit Important!']"
|
||||
|
||||
expect(page).to have_button count: 1
|
||||
expect(page).to have_css "button[aria-label='Delete Important!']", exact_text: "Delete"
|
||||
expect(page).to have_css "input[name='_method'][value='delete']", visible: :hidden
|
||||
end
|
||||
|
||||
context "actions parameter is passed" do
|
||||
@@ -18,13 +20,13 @@ describe Admin::TableActionsComponent, controller: Admin::BaseController do
|
||||
render_inline Admin::TableActionsComponent.new(record, actions: [:edit])
|
||||
|
||||
expect(page).to have_link "Edit"
|
||||
expect(page).not_to have_link "Delete"
|
||||
expect(page).not_to have_button "Delete"
|
||||
end
|
||||
|
||||
it "renders a link to destroy a record if passed" do
|
||||
it "renders a button to destroy a record if passed" do
|
||||
render_inline Admin::TableActionsComponent.new(record, actions: [:destroy])
|
||||
|
||||
expect(page).to have_link "Delete"
|
||||
expect(page).to have_button "Delete"
|
||||
expect(page).not_to have_link "Edit"
|
||||
end
|
||||
end
|
||||
@@ -32,9 +34,9 @@ describe Admin::TableActionsComponent, controller: Admin::BaseController do
|
||||
it "allows custom texts for actions" do
|
||||
render_inline Admin::TableActionsComponent.new(record, edit_text: "change", destroy_text: "annihilate")
|
||||
|
||||
expect(page).to have_link "annihilate"
|
||||
expect(page).to have_button "annihilate"
|
||||
expect(page).to have_link "change"
|
||||
expect(page).not_to have_link "Delete"
|
||||
expect(page).not_to have_button "Delete"
|
||||
expect(page).not_to have_link "Edit"
|
||||
end
|
||||
|
||||
@@ -42,13 +44,13 @@ describe Admin::TableActionsComponent, controller: Admin::BaseController do
|
||||
render_inline Admin::TableActionsComponent.new(record, edit_path: "/myedit", destroy_path: "/mydestroy")
|
||||
|
||||
expect(page).to have_link "Edit", href: "/myedit"
|
||||
expect(page).to have_link "Delete", href: "/mydestroy"
|
||||
expect(page).to have_css "form[action='/mydestroy']", exact_text: "Delete"
|
||||
end
|
||||
|
||||
it "allows custom confirmation text" do
|
||||
render_inline Admin::TableActionsComponent.new(record, destroy_confirmation: "Are you mad? Be careful!")
|
||||
|
||||
expect(page).to have_css "a[data-confirm='Are you mad? Be careful!']"
|
||||
expect(page).to have_css "button[data-confirm='Are you mad? Be careful!']"
|
||||
end
|
||||
|
||||
it "allows custom options" do
|
||||
@@ -62,19 +64,23 @@ describe Admin::TableActionsComponent, controller: Admin::BaseController do
|
||||
"<a href='/'>Main</a>".html_safe
|
||||
end
|
||||
|
||||
expect(page).to have_css "a", count: 3
|
||||
expect(page).to have_css "a", count: 2
|
||||
expect(page).to have_link "Main", href: "/"
|
||||
expect(page).to have_link "Edit"
|
||||
expect(page).to have_link "Delete"
|
||||
|
||||
expect(page).to have_button count: 1
|
||||
expect(page).to have_button "Delete"
|
||||
end
|
||||
|
||||
context "different namespace" do
|
||||
it "generates links to different namespaces", controller: SDGManagement::BaseController do
|
||||
it "generates actions to different namespaces", controller: SDGManagement::BaseController do
|
||||
render_inline Admin::TableActionsComponent.new(create(:sdg_local_target))
|
||||
|
||||
expect(page).to have_css "a", count: 2
|
||||
expect(page).to have_css "a[href^='/sdg_management/'][href*='edit']", text: "Edit"
|
||||
expect(page).to have_css "a[href^='/sdg_management/'][data-method='delete']", text: "Delete"
|
||||
expect(page).to have_link count: 1
|
||||
expect(page).to have_css "a[href^='/sdg_management/'][href*='edit']", exact_text: "Edit"
|
||||
|
||||
expect(page).to have_button count: 1
|
||||
expect(page).to have_css "form[action^='/sdg_management/']", exact_text: "Delete"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -113,7 +113,7 @@ shared_examples "admin_milestoneable" do |factory_name, path_name|
|
||||
|
||||
visit path
|
||||
|
||||
accept_confirm { click_link "Delete" }
|
||||
accept_confirm { click_button "Delete" }
|
||||
|
||||
expect(page).not_to have_content "Title will it remove"
|
||||
end
|
||||
|
||||
@@ -112,7 +112,7 @@ shared_examples "admin_progressable" do |factory_name, path_name|
|
||||
bar = create(:progress_bar, progressable: progressable, percentage: 34)
|
||||
|
||||
visit path
|
||||
within("#progress_bar_#{bar.id}") { accept_confirm { click_link "Delete" } }
|
||||
within("#progress_bar_#{bar.id}") { accept_confirm { click_button "Delete" } }
|
||||
|
||||
expect(page).to have_content "Progress bar deleted successfully"
|
||||
expect(page).not_to have_content "34%"
|
||||
|
||||
@@ -59,7 +59,7 @@ describe "Admin activity" do
|
||||
visit admin_hidden_proposals_path
|
||||
|
||||
within("#proposal_#{proposal.id}") do
|
||||
accept_confirm { click_link "Restore" }
|
||||
accept_confirm { click_button "Restore" }
|
||||
end
|
||||
|
||||
expect(page).to have_content "There are no hidden proposals"
|
||||
@@ -126,7 +126,7 @@ describe "Admin activity" do
|
||||
visit admin_hidden_debates_path
|
||||
|
||||
within("#debate_#{debate.id}") do
|
||||
accept_confirm { click_link "Restore" }
|
||||
accept_confirm { click_button "Restore" }
|
||||
end
|
||||
|
||||
expect(page).to have_content "There are no hidden debates"
|
||||
@@ -194,7 +194,7 @@ describe "Admin activity" do
|
||||
visit admin_hidden_comments_path
|
||||
|
||||
within("#comment_#{comment.id}") do
|
||||
accept_confirm { click_link "Restore" }
|
||||
accept_confirm { click_button "Restore" }
|
||||
end
|
||||
|
||||
expect(page).to have_content "There are no hidden comments"
|
||||
@@ -340,7 +340,7 @@ describe "Admin activity" do
|
||||
visit admin_hidden_users_path
|
||||
|
||||
within("#user_#{user.id}") do
|
||||
accept_confirm { click_link "Restore" }
|
||||
accept_confirm { click_button "Restore" }
|
||||
end
|
||||
|
||||
expect(page).to have_content "There are no hidden users"
|
||||
|
||||
@@ -118,7 +118,7 @@ describe "Admin Notifications", :admin do
|
||||
|
||||
visit admin_admin_notifications_path
|
||||
within("#admin_notification_#{notification.id}") do
|
||||
accept_confirm { click_link "Delete" }
|
||||
accept_confirm { click_button "Delete" }
|
||||
end
|
||||
|
||||
expect(page).to have_content "Notification deleted successfully"
|
||||
@@ -129,8 +129,9 @@ describe "Admin Notifications", :admin do
|
||||
notification = create(:admin_notification, :sent)
|
||||
|
||||
visit admin_admin_notifications_path
|
||||
|
||||
within("#admin_notification_#{notification.id}") do
|
||||
expect(page).not_to have_link("Delete")
|
||||
expect(page).not_to have_button "Delete"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -24,7 +24,9 @@ describe "Admin administrators" do
|
||||
click_button "Search"
|
||||
|
||||
expect(page).to have_content user.name
|
||||
click_link "Add"
|
||||
|
||||
click_button "Add"
|
||||
|
||||
within("#administrators") do
|
||||
expect(page).to have_content user.name
|
||||
end
|
||||
@@ -34,7 +36,7 @@ describe "Admin administrators" do
|
||||
visit admin_administrators_path
|
||||
|
||||
within "#administrator_#{user_administrator.id}" do
|
||||
accept_confirm { click_link "Delete" }
|
||||
accept_confirm { click_button "Delete" }
|
||||
end
|
||||
|
||||
within("#administrators") do
|
||||
@@ -46,7 +48,7 @@ describe "Admin administrators" do
|
||||
visit admin_administrators_path
|
||||
|
||||
within "#administrator_#{admin.id}" do
|
||||
accept_confirm { click_link "Delete" }
|
||||
accept_confirm { click_button "Delete" }
|
||||
end
|
||||
|
||||
within("#error") do
|
||||
@@ -110,7 +112,7 @@ describe "Admin administrators" do
|
||||
fill_in "Search user by name or email", with: administrator2.email
|
||||
click_button "Search"
|
||||
|
||||
accept_confirm { click_link "Delete" }
|
||||
accept_confirm { click_button "Delete" }
|
||||
|
||||
expect(page).to have_content(administrator1.email)
|
||||
expect(page).not_to have_content(administrator2.email)
|
||||
|
||||
@@ -173,7 +173,7 @@ describe "Admin banners magement", :admin do
|
||||
|
||||
expect(page).to have_content "Ugly banner"
|
||||
|
||||
accept_confirm { click_link "Delete" }
|
||||
accept_confirm { click_button "Delete" }
|
||||
|
||||
visit admin_root_path
|
||||
expect(page).not_to have_content "Ugly banner"
|
||||
|
||||
@@ -59,7 +59,7 @@ describe "Admin budget groups", :admin do
|
||||
group = create(:budget_group, budget: budget)
|
||||
|
||||
visit admin_budget_groups_path(budget)
|
||||
within("#budget_group_#{group.id}") { accept_confirm { click_link "Delete" } }
|
||||
within("#budget_group_#{group.id}") { accept_confirm { click_button "Delete" } }
|
||||
|
||||
expect(page).to have_content "Group deleted successfully"
|
||||
expect(page).not_to have_selector "#budget_group_#{group.id}"
|
||||
@@ -70,7 +70,7 @@ describe "Admin budget groups", :admin do
|
||||
create(:budget_heading, group: group)
|
||||
|
||||
visit admin_budget_groups_path(budget)
|
||||
within("#budget_group_#{group.id}") { accept_confirm { click_link "Delete" } }
|
||||
within("#budget_group_#{group.id}") { accept_confirm { click_button "Delete" } }
|
||||
|
||||
expect(page).to have_content "You cannot delete a Group that has associated headings"
|
||||
expect(page).to have_selector "#budget_group_#{group.id}"
|
||||
|
||||
@@ -38,7 +38,7 @@ describe "Admin budget headings", :admin do
|
||||
expect(page).not_to have_content "10000"
|
||||
expect(page).to have_content "Yes"
|
||||
expect(page).to have_link "Edit"
|
||||
expect(page).to have_link "Delete"
|
||||
expect(page).to have_button "Delete"
|
||||
end
|
||||
|
||||
within "#budget_heading_#{heading2.id}" do
|
||||
@@ -47,7 +47,7 @@ describe "Admin budget headings", :admin do
|
||||
expect(page).to have_content "10000"
|
||||
expect(page).to have_content "No"
|
||||
expect(page).to have_link "Edit"
|
||||
expect(page).to have_link "Delete"
|
||||
expect(page).to have_button "Delete"
|
||||
end
|
||||
|
||||
within "#budget_heading_#{heading3.id}" do
|
||||
@@ -56,7 +56,7 @@ describe "Admin budget headings", :admin do
|
||||
expect(page).to have_content "10000"
|
||||
expect(page).to have_content "No"
|
||||
expect(page).to have_link "Edit"
|
||||
expect(page).to have_link "Delete"
|
||||
expect(page).to have_button "Delete"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -64,7 +64,7 @@ describe "Admin budget headings", :admin do
|
||||
heading = create(:budget_heading, group: group)
|
||||
|
||||
visit admin_budget_group_headings_path(budget, group)
|
||||
within("#budget_heading_#{heading.id}") { accept_confirm { click_link "Delete" } }
|
||||
within("#budget_heading_#{heading.id}") { accept_confirm { click_button "Delete" } }
|
||||
|
||||
expect(page).to have_content "Heading deleted successfully"
|
||||
expect(page).not_to have_selector "#budget_heading_#{heading.id}"
|
||||
@@ -75,7 +75,7 @@ describe "Admin budget headings", :admin do
|
||||
create(:budget_investment, heading: heading)
|
||||
|
||||
visit admin_budget_group_headings_path(budget, group)
|
||||
within(".heading", text: "Atlantis") { accept_confirm { click_link "Delete" } }
|
||||
within(".heading", text: "Atlantis") { accept_confirm { click_button "Delete" } }
|
||||
|
||||
expect(page).to have_content "You cannot delete a Heading that has associated investments"
|
||||
expect(page).to have_content "Atlantis"
|
||||
|
||||
@@ -101,7 +101,7 @@ describe "Admin budgets", :admin do
|
||||
within "tr", text: "To be deleted" do
|
||||
message = "Are you sure? This action will delete \"To be deleted\" and can't be undone."
|
||||
|
||||
accept_confirm(message) { click_link "Delete" }
|
||||
accept_confirm(message) { click_button "Delete" }
|
||||
end
|
||||
|
||||
expect(page).to have_content("Budget deleted successfully")
|
||||
|
||||
@@ -124,7 +124,7 @@ describe "Budgets wizard, groups step", :admin do
|
||||
create(:budget_group, budget: budget, name: "Delete me!")
|
||||
|
||||
visit admin_budgets_wizard_budget_groups_path(budget)
|
||||
within("tr", text: "Delete me!") { accept_confirm { click_link "Delete" } }
|
||||
within("tr", text: "Delete me!") { accept_confirm { click_button "Delete" } }
|
||||
|
||||
expect(page).to have_content "Group deleted successfully"
|
||||
expect(page).not_to have_content "Delete me!"
|
||||
@@ -137,7 +137,7 @@ describe "Budgets wizard, groups step", :admin do
|
||||
|
||||
visit admin_budgets_wizard_budget_groups_path(budget)
|
||||
|
||||
within("tr", text: "Don't delete me!") { accept_confirm { click_link "Delete" } }
|
||||
within("tr", text: "Don't delete me!") { accept_confirm { click_button "Delete" } }
|
||||
|
||||
expect(page).to have_content "You cannot delete a Group that has associated headings"
|
||||
expect(page).to have_content "Don't delete me!"
|
||||
|
||||
@@ -148,7 +148,7 @@ describe "Budgets wizard, headings step", :admin do
|
||||
create(:budget_heading, group: group, name: "Delete me!")
|
||||
|
||||
visit admin_budgets_wizard_budget_group_headings_path(budget, group)
|
||||
within("tr", text: "Delete me!") { accept_confirm { click_link "Delete" } }
|
||||
within("tr", text: "Delete me!") { accept_confirm { click_button "Delete" } }
|
||||
|
||||
expect(page).to have_content "Heading deleted successfully"
|
||||
expect(page).not_to have_content "Delete me!"
|
||||
@@ -161,7 +161,7 @@ describe "Budgets wizard, headings step", :admin do
|
||||
|
||||
visit admin_budgets_wizard_budget_group_headings_path(budget, group)
|
||||
|
||||
within("tr", text: "Don't delete me!") { accept_confirm { click_link "Delete" } }
|
||||
within("tr", text: "Don't delete me!") { accept_confirm { click_button "Delete" } }
|
||||
|
||||
expect(page).to have_content "You cannot delete a Heading that has associated investments"
|
||||
expect(page).to have_content "Don't delete me!"
|
||||
|
||||
@@ -94,9 +94,7 @@ describe "Admin dashboard actions", :admin do
|
||||
end
|
||||
|
||||
scenario "deletes the action" do
|
||||
page.accept_confirm do
|
||||
click_link "Delete"
|
||||
end
|
||||
accept_confirm { click_button "Delete" }
|
||||
|
||||
expect(page).not_to have_content(action.title)
|
||||
end
|
||||
@@ -104,9 +102,7 @@ describe "Admin dashboard actions", :admin do
|
||||
scenario "can not delete actions that have been executed" do
|
||||
_executed_action = create(:dashboard_executed_action, action: action)
|
||||
|
||||
page.accept_confirm do
|
||||
click_link "Delete"
|
||||
end
|
||||
accept_confirm { click_button "Delete" }
|
||||
|
||||
expect(page).to have_content("Cannot delete record because dependent executed actions exist")
|
||||
end
|
||||
|
||||
@@ -103,7 +103,7 @@ describe "Admin newsletter emails", :admin do
|
||||
|
||||
visit admin_newsletters_path
|
||||
within("#newsletter_#{newsletter.id}") do
|
||||
accept_confirm { click_link "Delete" }
|
||||
accept_confirm { click_button "Delete" }
|
||||
end
|
||||
|
||||
expect(page).to have_content "Newsletter deleted successfully"
|
||||
|
||||
@@ -74,7 +74,7 @@ describe "Admin geozones", :admin do
|
||||
|
||||
visit admin_geozones_path
|
||||
|
||||
within("#geozone_#{geozone.id}") { accept_confirm { click_link "Delete" } }
|
||||
within("#geozone_#{geozone.id}") { accept_confirm { click_button "Delete" } }
|
||||
|
||||
expect(page).to have_content "Geozone successfully deleted"
|
||||
expect(page).not_to have_content("Delete me!")
|
||||
@@ -86,7 +86,7 @@ describe "Admin geozones", :admin do
|
||||
|
||||
visit admin_geozones_path
|
||||
|
||||
within("#geozone_#{geozone.id}") { accept_confirm { click_link "Delete" } }
|
||||
within("#geozone_#{geozone.id}") { accept_confirm { click_button "Delete" } }
|
||||
|
||||
expect(page).to have_content "This geozone can't be deleted since there are elements attached to it"
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ describe "Admin hidden budget investments", :admin do
|
||||
|
||||
visit admin_hidden_budget_investments_path
|
||||
|
||||
accept_confirm { click_link "Restore" }
|
||||
accept_confirm { click_button "Restore" }
|
||||
|
||||
expect(page).not_to have_content(investment.title)
|
||||
|
||||
@@ -36,7 +36,7 @@ describe "Admin hidden budget investments", :admin do
|
||||
expect(page).not_to have_link "Pending"
|
||||
expect(page).to have_content(investment.title)
|
||||
|
||||
click_link "Confirm moderation"
|
||||
click_button "Confirm moderation"
|
||||
|
||||
expect(page).not_to have_content(investment.title)
|
||||
|
||||
@@ -84,7 +84,7 @@ describe "Admin hidden budget investments", :admin do
|
||||
|
||||
visit admin_hidden_budget_investments_path(filter: "with_confirmed_hide", page: 2)
|
||||
|
||||
accept_confirm { click_link "Restore", match: :first, exact: true }
|
||||
accept_confirm { click_button "Restore", match: :first, exact: true }
|
||||
|
||||
expect(page).to have_current_path(/filter=with_confirmed_hide/)
|
||||
expect(page).to have_current_path(/page=2/)
|
||||
|
||||
@@ -67,7 +67,7 @@ describe "Admin hidden comments", :admin do
|
||||
comment = create(:comment, :hidden, body: "Not really SPAM")
|
||||
visit admin_hidden_comments_path
|
||||
|
||||
accept_confirm { click_link "Restore" }
|
||||
accept_confirm { click_button "Restore" }
|
||||
|
||||
expect(page).not_to have_content(comment.body)
|
||||
|
||||
@@ -80,7 +80,7 @@ describe "Admin hidden comments", :admin do
|
||||
comment = create(:comment, :hidden, body: "SPAM")
|
||||
visit admin_hidden_comments_path
|
||||
|
||||
click_link "Confirm moderation"
|
||||
click_button "Confirm moderation"
|
||||
|
||||
expect(page).not_to have_content(comment.body)
|
||||
click_link("Confirmed")
|
||||
@@ -128,7 +128,7 @@ describe "Admin hidden comments", :admin do
|
||||
|
||||
visit admin_hidden_comments_path(filter: "with_confirmed_hide", page: 2)
|
||||
|
||||
accept_confirm { click_link "Restore", match: :first, exact: true }
|
||||
accept_confirm { click_button "Restore", match: :first, exact: true }
|
||||
|
||||
expect(page).to have_current_path(/filter=with_confirmed_hide/)
|
||||
expect(page).to have_current_path(/page=2/)
|
||||
|
||||
@@ -5,7 +5,7 @@ describe "Admin hidden debates", :admin do
|
||||
debate = create(:debate, :hidden)
|
||||
visit admin_hidden_debates_path
|
||||
|
||||
accept_confirm { click_link "Restore" }
|
||||
accept_confirm { click_button "Restore" }
|
||||
|
||||
expect(page).not_to have_content(debate.title)
|
||||
|
||||
@@ -18,7 +18,7 @@ describe "Admin hidden debates", :admin do
|
||||
debate = create(:debate, :hidden)
|
||||
visit admin_hidden_debates_path
|
||||
|
||||
click_link "Confirm moderation"
|
||||
click_button "Confirm moderation"
|
||||
|
||||
expect(page).not_to have_content(debate.title)
|
||||
click_link("Confirmed")
|
||||
@@ -70,7 +70,7 @@ describe "Admin hidden debates", :admin do
|
||||
|
||||
visit admin_hidden_debates_path(filter: "with_confirmed_hide", page: 2)
|
||||
|
||||
accept_confirm { click_link "Restore", match: :first, exact: true }
|
||||
accept_confirm { click_button "Restore", match: :first, exact: true }
|
||||
|
||||
expect(page).to have_current_path(/filter=with_confirmed_hide/)
|
||||
expect(page).to have_current_path(/page=2/)
|
||||
|
||||
@@ -18,7 +18,7 @@ describe "Admin hidden proposals", :admin do
|
||||
proposal = create(:proposal, :hidden)
|
||||
visit admin_hidden_proposals_path
|
||||
|
||||
accept_confirm { click_link "Restore" }
|
||||
accept_confirm { click_button "Restore" }
|
||||
|
||||
expect(page).not_to have_content(proposal.title)
|
||||
|
||||
@@ -31,7 +31,7 @@ describe "Admin hidden proposals", :admin do
|
||||
proposal = create(:proposal, :hidden)
|
||||
visit admin_hidden_proposals_path
|
||||
|
||||
click_link "Confirm moderation"
|
||||
click_button "Confirm moderation"
|
||||
|
||||
expect(page).not_to have_content(proposal.title)
|
||||
click_link("Confirmed")
|
||||
@@ -83,7 +83,7 @@ describe "Admin hidden proposals", :admin do
|
||||
|
||||
visit admin_hidden_proposals_path(filter: "with_confirmed_hide", page: 2)
|
||||
|
||||
accept_confirm { click_link "Restore", match: :first, exact: true }
|
||||
accept_confirm { click_button "Restore", match: :first, exact: true }
|
||||
|
||||
expect(page).to have_current_path(/filter=with_confirmed_hide/)
|
||||
expect(page).to have_current_path(/page=2/)
|
||||
|
||||
@@ -21,7 +21,7 @@ describe "Admin hidden users", :admin do
|
||||
user = create(:user, :hidden)
|
||||
visit admin_hidden_users_path
|
||||
|
||||
accept_confirm { click_link "Restore" }
|
||||
accept_confirm { click_button "Restore" }
|
||||
|
||||
expect(page).not_to have_content(user.username)
|
||||
|
||||
@@ -34,7 +34,7 @@ describe "Admin hidden users", :admin do
|
||||
user = create(:user, :hidden)
|
||||
visit admin_hidden_users_path
|
||||
|
||||
click_link "Confirm moderation"
|
||||
click_button "Confirm moderation"
|
||||
|
||||
expect(page).not_to have_content(user.username)
|
||||
click_link("Confirmed")
|
||||
@@ -82,7 +82,7 @@ describe "Admin hidden users", :admin do
|
||||
|
||||
visit admin_hidden_users_path(filter: "with_confirmed_hide", page: 2)
|
||||
|
||||
accept_confirm { click_link "Restore", match: :first, exact: true }
|
||||
accept_confirm { click_button "Restore", match: :first, exact: true }
|
||||
|
||||
expect(page).to have_current_path(/filter=with_confirmed_hide/)
|
||||
expect(page).to have_current_path(/page=2/)
|
||||
|
||||
@@ -25,7 +25,7 @@ describe "Admin local census records", :admin do
|
||||
|
||||
within "#local_census_record_#{local_census_record.id}" do
|
||||
expect(page).to have_link "Edit"
|
||||
expect(page).to have_link "Delete"
|
||||
expect(page).to have_button "Delete"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -19,7 +19,9 @@ describe "Admin managers", :admin do
|
||||
click_button "Search"
|
||||
|
||||
expect(page).to have_content user.name
|
||||
click_link "Add"
|
||||
|
||||
click_button "Add"
|
||||
|
||||
within("#managers") do
|
||||
expect(page).to have_content user.name
|
||||
end
|
||||
@@ -28,7 +30,7 @@ describe "Admin managers", :admin do
|
||||
scenario "Delete Manager" do
|
||||
visit admin_managers_path
|
||||
|
||||
accept_confirm { click_link "Delete" }
|
||||
accept_confirm { click_button "Delete" }
|
||||
|
||||
within("#managers") do
|
||||
expect(page).not_to have_content manager.name
|
||||
@@ -88,7 +90,7 @@ describe "Admin managers", :admin do
|
||||
fill_in "Search user by name or email", with: manager2.email
|
||||
click_button "Search"
|
||||
|
||||
accept_confirm { click_link "Delete" }
|
||||
accept_confirm { click_button "Delete" }
|
||||
|
||||
expect(page).to have_content(manager1.email)
|
||||
expect(page).not_to have_content(manager2.email)
|
||||
|
||||
@@ -78,7 +78,7 @@ describe "Admin milestone statuses", :admin do
|
||||
visit admin_milestone_statuses_path
|
||||
|
||||
within("#milestone_status_#{status.id}") do
|
||||
accept_confirm { click_link "Delete" }
|
||||
accept_confirm { click_button "Delete" }
|
||||
end
|
||||
|
||||
expect(page).not_to have_content status.name
|
||||
|
||||
@@ -19,7 +19,9 @@ describe "Admin moderators", :admin do
|
||||
click_button "Search"
|
||||
|
||||
expect(page).to have_content user.name
|
||||
click_link "Add"
|
||||
|
||||
click_button "Add"
|
||||
|
||||
within("#moderators") do
|
||||
expect(page).to have_content user.name
|
||||
end
|
||||
@@ -28,7 +30,7 @@ describe "Admin moderators", :admin do
|
||||
scenario "Delete Moderator" do
|
||||
visit admin_moderators_path
|
||||
|
||||
accept_confirm { click_link "Delete" }
|
||||
accept_confirm { click_button "Delete" }
|
||||
|
||||
within("#moderators") do
|
||||
expect(page).not_to have_content moderator.name
|
||||
@@ -88,7 +90,7 @@ describe "Admin moderators", :admin do
|
||||
fill_in "Search user by name or email", with: moderator2.email
|
||||
click_button "Search"
|
||||
|
||||
accept_confirm { click_link "Delete" }
|
||||
accept_confirm { click_button "Delete" }
|
||||
|
||||
expect(page).to have_content(moderator1.email)
|
||||
expect(page).not_to have_content(moderator2.email)
|
||||
|
||||
@@ -88,10 +88,10 @@ describe "Admin::Organizations" do
|
||||
visit admin_organizations_path
|
||||
within("#organization_#{organization.id}") do
|
||||
expect(page).to have_current_path(admin_organizations_path, ignore_query: true)
|
||||
expect(page).to have_link("Verify")
|
||||
expect(page).to have_link("Reject")
|
||||
expect(page).to have_button "Verify"
|
||||
expect(page).to have_button "Reject"
|
||||
|
||||
click_on "Verify"
|
||||
click_button "Verify"
|
||||
end
|
||||
expect(page).to have_current_path(admin_organizations_path, ignore_query: true)
|
||||
|
||||
@@ -111,10 +111,10 @@ describe "Admin::Organizations" do
|
||||
|
||||
within("#organization_#{organization.id}") do
|
||||
expect(page).to have_content "Verified"
|
||||
expect(page).not_to have_link("Verify")
|
||||
expect(page).to have_link("Reject")
|
||||
expect(page).to have_button "Reject"
|
||||
expect(page).not_to have_button "Verify"
|
||||
|
||||
click_on "Reject"
|
||||
click_button "Reject"
|
||||
end
|
||||
expect(page).to have_current_path(admin_organizations_path, ignore_query: true)
|
||||
expect(page).not_to have_content organization.name
|
||||
@@ -133,10 +133,10 @@ describe "Admin::Organizations" do
|
||||
click_on "Rejected"
|
||||
|
||||
within("#organization_#{organization.id}") do
|
||||
expect(page).to have_link("Verify")
|
||||
expect(page).not_to have_link("Reject", exact: true)
|
||||
expect(page).to have_button "Verify"
|
||||
expect(page).not_to have_button "Reject"
|
||||
|
||||
click_on "Verify"
|
||||
click_button "Verify"
|
||||
end
|
||||
expect(page).to have_current_path(admin_organizations_path, ignore_query: true)
|
||||
expect(page).not_to have_content organization.name
|
||||
@@ -211,7 +211,7 @@ describe "Admin::Organizations" do
|
||||
|
||||
visit admin_organizations_path(filter: "pending", page: 2)
|
||||
|
||||
click_on("Verify", match: :first)
|
||||
click_button "Verify", match: :first
|
||||
|
||||
expect(page).to have_current_path(/filter=pending/)
|
||||
expect(page).to have_current_path(/page=2/)
|
||||
|
||||
@@ -61,11 +61,11 @@ describe "Admin booths assignments", :admin do
|
||||
expect(page).to have_content(booth.name)
|
||||
expect(page).to have_content "Unassigned"
|
||||
|
||||
click_link "Assign booth"
|
||||
click_button "Assign booth"
|
||||
|
||||
expect(page).not_to have_content "Unassigned"
|
||||
expect(page).to have_content "Assigned"
|
||||
expect(page).to have_link "Unassign booth"
|
||||
expect(page).to have_button "Unassign booth"
|
||||
end
|
||||
|
||||
visit admin_poll_path(poll)
|
||||
@@ -100,11 +100,11 @@ describe "Admin booths assignments", :admin do
|
||||
expect(page).to have_content(booth.name)
|
||||
expect(page).to have_content "Assigned"
|
||||
|
||||
click_link "Unassign booth"
|
||||
click_button "Unassign booth"
|
||||
|
||||
expect(page).to have_content "Unassigned"
|
||||
expect(page).not_to have_content "Assigned"
|
||||
expect(page).to have_link "Assign booth"
|
||||
expect(page).to have_button "Assign booth"
|
||||
end
|
||||
|
||||
visit admin_poll_path(poll)
|
||||
@@ -127,11 +127,11 @@ describe "Admin booths assignments", :admin do
|
||||
expect(page).to have_content(booth.name)
|
||||
expect(page).to have_content "Assigned"
|
||||
|
||||
accept_confirm { click_link "Unassign booth" }
|
||||
accept_confirm { click_button "Unassign booth" }
|
||||
|
||||
expect(page).to have_content "Unassigned"
|
||||
expect(page).not_to have_content "Assigned"
|
||||
expect(page).to have_link "Assign booth"
|
||||
expect(page).to have_button "Assign booth"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -143,8 +143,7 @@ describe "Admin booths assignments", :admin do
|
||||
within("#poll_booth_#{booth.id}") do
|
||||
expect(page).to have_content(booth.name)
|
||||
expect(page).to have_content "Assigned"
|
||||
|
||||
expect(page).not_to have_link "Unassign booth"
|
||||
expect(page).not_to have_button "Unassign booth"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -19,14 +19,16 @@ describe "Admin poll officers", :admin do
|
||||
click_button "Search"
|
||||
|
||||
expect(page).to have_content user.name
|
||||
click_link "Add"
|
||||
|
||||
click_button "Add"
|
||||
|
||||
within("#officers") do
|
||||
expect(page).to have_content user.name
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Delete" do
|
||||
accept_confirm { click_link "Delete position" }
|
||||
accept_confirm { click_button "Delete position" }
|
||||
|
||||
expect(page).not_to have_css "#officers"
|
||||
end
|
||||
|
||||
@@ -119,7 +119,7 @@ describe "Admin polls", :admin do
|
||||
visit admin_polls_path
|
||||
|
||||
within("#poll_#{poll.id}") do
|
||||
accept_confirm { click_link "Delete" }
|
||||
accept_confirm { click_button "Delete" }
|
||||
end
|
||||
|
||||
expect(page).to have_content("Poll deleted successfully")
|
||||
@@ -133,7 +133,7 @@ describe "Admin polls", :admin do
|
||||
visit admin_polls_path
|
||||
|
||||
within(".poll", text: "Do you support CONSUL?") do
|
||||
accept_confirm { click_link "Delete" }
|
||||
accept_confirm { click_button "Delete" }
|
||||
end
|
||||
|
||||
expect(page).to have_content("Poll deleted successfully")
|
||||
@@ -150,7 +150,7 @@ describe "Admin polls", :admin do
|
||||
visit admin_polls_path
|
||||
|
||||
within(".poll", text: "Do you support CONSUL?") do
|
||||
accept_confirm { click_link "Delete" }
|
||||
accept_confirm { click_button "Delete" }
|
||||
end
|
||||
|
||||
expect(page).to have_content "Poll deleted successfully"
|
||||
@@ -164,7 +164,7 @@ describe "Admin polls", :admin do
|
||||
visit admin_polls_path
|
||||
|
||||
within("#poll_#{poll.id}") do
|
||||
accept_confirm { click_link "Delete" }
|
||||
accept_confirm { click_button "Delete" }
|
||||
end
|
||||
|
||||
expect(page).to have_content("You cannot delete a poll that has votes")
|
||||
|
||||
@@ -28,7 +28,7 @@ describe "Documents", :admin do
|
||||
visit admin_answer_documents_path(answer)
|
||||
expect(page).to have_content(document.title)
|
||||
|
||||
accept_confirm { click_link "Delete" }
|
||||
accept_confirm { click_button "Delete" }
|
||||
|
||||
expect(page).not_to have_content(document.title)
|
||||
end
|
||||
|
||||
@@ -17,7 +17,7 @@ describe "Admin poll questions", :admin do
|
||||
expect(page).to have_content(question1.title)
|
||||
expect(page).to have_link "Edit answers"
|
||||
expect(page).to have_link "Edit"
|
||||
expect(page).to have_link "Delete"
|
||||
expect(page).to have_button "Delete"
|
||||
end
|
||||
|
||||
visit admin_poll_path(poll2)
|
||||
@@ -27,7 +27,7 @@ describe "Admin poll questions", :admin do
|
||||
expect(page).to have_content question2.title
|
||||
expect(page).to have_link "Edit answers"
|
||||
expect(page).to have_link "Edit"
|
||||
expect(page).to have_link "Delete"
|
||||
expect(page).to have_button "Delete"
|
||||
end
|
||||
|
||||
visit admin_poll_path(poll3)
|
||||
@@ -38,7 +38,7 @@ describe "Admin poll questions", :admin do
|
||||
expect(page).to have_link "(See proposal)", href: proposal_path(question3.proposal)
|
||||
expect(page).to have_link "Edit answers"
|
||||
expect(page).to have_link "Edit"
|
||||
expect(page).to have_link "Delete"
|
||||
expect(page).to have_button "Delete"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -142,7 +142,7 @@ describe "Admin poll questions", :admin do
|
||||
visit admin_poll_path(poll)
|
||||
|
||||
within("#poll_question_#{question1.id}") do
|
||||
accept_confirm { click_link "Delete" }
|
||||
accept_confirm { click_button "Delete" }
|
||||
end
|
||||
|
||||
expect(page).not_to have_content(question1.title)
|
||||
|
||||
@@ -174,7 +174,7 @@ describe "Admin shifts", :admin do
|
||||
|
||||
expect(page).to have_css(".shift", count: 1)
|
||||
within("#shift_#{shift.id}") do
|
||||
accept_confirm { click_link "Remove" }
|
||||
accept_confirm { click_button "Remove" }
|
||||
end
|
||||
|
||||
expect(page).to have_content "Shift removed"
|
||||
@@ -198,7 +198,7 @@ describe "Admin shifts", :admin do
|
||||
|
||||
expect(page).to have_css(".shift", count: 1)
|
||||
within("#shift_#{shift.id}") do
|
||||
accept_confirm { click_link "Remove" }
|
||||
accept_confirm { click_button "Remove" }
|
||||
end
|
||||
|
||||
expect(page).not_to have_content "Shift removed"
|
||||
@@ -225,7 +225,7 @@ describe "Admin shifts", :admin do
|
||||
|
||||
expect(page).to have_css(".shift", count: 1)
|
||||
within("#shift_#{shift.id}") do
|
||||
accept_confirm { click_link "Remove" }
|
||||
accept_confirm { click_button "Remove" }
|
||||
end
|
||||
|
||||
expect(page).not_to have_content "Shift removed"
|
||||
|
||||
@@ -13,7 +13,7 @@ describe "Admin proposal notifications", :admin do
|
||||
proposal_notification = create(:proposal_notification, :hidden, created_at: Date.current - 5.days)
|
||||
visit admin_hidden_proposal_notifications_path
|
||||
|
||||
accept_confirm { click_link "Restore" }
|
||||
accept_confirm { click_button "Restore" }
|
||||
|
||||
expect(page).not_to have_content(proposal_notification.title)
|
||||
|
||||
@@ -28,7 +28,7 @@ describe "Admin proposal notifications", :admin do
|
||||
proposal_notification = create(:proposal_notification, :hidden, created_at: Date.current - 5.days)
|
||||
visit admin_hidden_proposal_notifications_path
|
||||
|
||||
click_link "Confirm moderation"
|
||||
click_button "Confirm moderation"
|
||||
|
||||
expect(page).not_to have_content(proposal_notification.title)
|
||||
click_link("Confirmed")
|
||||
@@ -80,7 +80,7 @@ describe "Admin proposal notifications", :admin do
|
||||
|
||||
visit admin_hidden_proposal_notifications_path(filter: "with_confirmed_hide", page: 2)
|
||||
|
||||
accept_confirm { click_link "Restore", match: :first, exact: true }
|
||||
accept_confirm { click_button "Restore", match: :first, exact: true }
|
||||
|
||||
expect(page).to have_current_path(/filter=with_confirmed_hide/)
|
||||
expect(page).to have_current_path(/page=2/)
|
||||
|
||||
@@ -22,7 +22,7 @@ describe "Admin SDG managers" do
|
||||
|
||||
expect(page).to have_content user.name
|
||||
|
||||
click_link "Add"
|
||||
click_button "Add"
|
||||
|
||||
within("#sdg_managers") do
|
||||
expect(page).to have_content user.name
|
||||
@@ -32,7 +32,7 @@ describe "Admin SDG managers" do
|
||||
scenario "Delete SDG Manager" do
|
||||
visit admin_sdg_managers_path
|
||||
|
||||
accept_confirm { click_link "Delete" }
|
||||
accept_confirm { click_button "Delete" }
|
||||
|
||||
within("#sdg_managers") do
|
||||
expect(page).not_to have_content sdg_manager.name
|
||||
@@ -90,7 +90,7 @@ describe "Admin SDG managers" do
|
||||
fill_in "Search user by name or email", with: sdg_manager2.email
|
||||
click_button "Search"
|
||||
|
||||
accept_confirm { click_link "Delete" }
|
||||
accept_confirm { click_button "Delete" }
|
||||
|
||||
expect(page).to have_content(sdg_manager1.email)
|
||||
expect(page).not_to have_content(sdg_manager2.email)
|
||||
|
||||
@@ -91,7 +91,7 @@ describe "Admin custom content blocks", :admin do
|
||||
expect(page).to have_content("#{block.name} (#{block.locale})")
|
||||
expect(page).to have_content(block.body)
|
||||
|
||||
accept_confirm { click_link "Delete" }
|
||||
accept_confirm { click_button "Delete" }
|
||||
|
||||
expect(page).not_to have_content("#{block.name} (#{block.locale})")
|
||||
expect(page).not_to have_content(block.body)
|
||||
|
||||
@@ -75,7 +75,7 @@ describe "Documents", :admin do
|
||||
visit admin_site_customization_documents_path
|
||||
|
||||
within("#document_#{document.id}") do
|
||||
accept_confirm { click_link "Delete" }
|
||||
accept_confirm { click_button "Delete" }
|
||||
end
|
||||
|
||||
expect(page).to have_content "Document deleted succesfully"
|
||||
|
||||
@@ -36,8 +36,10 @@ describe "System Emails" do
|
||||
within("##{email_id}") do
|
||||
expect(page).to have_link("Preview Pending",
|
||||
href: admin_system_email_preview_pending_path(email_id))
|
||||
expect(page).to have_link("Send pending",
|
||||
href: admin_system_email_send_pending_path(email_id))
|
||||
|
||||
within "form[action='#{admin_system_email_send_pending_path(email_id)}']" do
|
||||
expect(page).to have_button "Send pending"
|
||||
end
|
||||
|
||||
expect(page).not_to have_content "You can edit this email in"
|
||||
expect(page).not_to have_content "app/views/mailer/#{email_id}.html.erb"
|
||||
@@ -57,7 +59,7 @@ describe "System Emails" do
|
||||
expect(page).to have_content "app/views/mailer/#{email_id}.html.erb"
|
||||
|
||||
expect(page).not_to have_link "Preview Pending"
|
||||
expect(page).not_to have_link "Send pending"
|
||||
expect(page).not_to have_button "Send pending"
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -327,7 +329,7 @@ describe "System Emails" do
|
||||
|
||||
visit admin_system_emails_path
|
||||
|
||||
click_on "Send pending"
|
||||
click_button "Send pending"
|
||||
|
||||
email = open_last_email
|
||||
expect(email).to deliver_to(voter)
|
||||
|
||||
@@ -39,7 +39,7 @@ describe "Admin tags", :admin do
|
||||
expect(page).to have_content "bad tag"
|
||||
|
||||
within("#tag_#{tag2.id}") do
|
||||
accept_confirm { click_link "Delete" }
|
||||
accept_confirm { click_button "Delete" }
|
||||
end
|
||||
|
||||
expect(page).not_to have_content "bad tag"
|
||||
@@ -57,7 +57,7 @@ describe "Admin tags", :admin do
|
||||
expect(page).to have_content "bad tag"
|
||||
|
||||
within("#tag_#{tag2.id}") do
|
||||
accept_confirm { click_link "Delete" }
|
||||
accept_confirm { click_button "Delete" }
|
||||
end
|
||||
|
||||
expect(page).not_to have_content "bad tag"
|
||||
|
||||
@@ -67,7 +67,7 @@ describe "Valuator groups", :admin do
|
||||
create(:valuator_group)
|
||||
|
||||
visit admin_valuator_groups_path
|
||||
accept_confirm { click_link "Delete" }
|
||||
accept_confirm { click_button "Delete" }
|
||||
|
||||
expect(page).to have_content "Valuator group deleted successfully"
|
||||
expect(page).to have_content "There are no valuator groups"
|
||||
|
||||
@@ -55,7 +55,7 @@ describe "Admin valuators", :admin do
|
||||
scenario "Destroy" do
|
||||
visit admin_valuators_path
|
||||
|
||||
accept_confirm { click_link "Delete" }
|
||||
accept_confirm { click_button "Delete" }
|
||||
|
||||
within("#valuators") do
|
||||
expect(page).not_to have_content(valuator.name)
|
||||
|
||||
@@ -110,9 +110,7 @@ describe "Cards", :admin do
|
||||
visit admin_homepage_path
|
||||
|
||||
within("#widget_card_#{card.id}") do
|
||||
accept_confirm do
|
||||
click_link "Delete"
|
||||
end
|
||||
accept_confirm { click_button "Delete" }
|
||||
end
|
||||
|
||||
expect(page).to have_content "Card removed successfully"
|
||||
@@ -238,9 +236,7 @@ describe "Cards", :admin do
|
||||
|
||||
expect(page).to have_content("Card title")
|
||||
|
||||
accept_confirm do
|
||||
click_link "Delete"
|
||||
end
|
||||
accept_confirm { click_button "Delete" }
|
||||
|
||||
expect(page).to have_current_path admin_site_customization_page_widget_cards_path(custom_page)
|
||||
expect(page).not_to have_content "Card title"
|
||||
|
||||
@@ -8,7 +8,7 @@ describe "Admin Budgets", :admin do
|
||||
|
||||
visit admin_budgets_path
|
||||
|
||||
click_link "Ballots"
|
||||
click_button "Ballots"
|
||||
|
||||
expect(page).to have_current_path(/admin\/polls\/\d+/)
|
||||
expect(page).to have_content(budget.name)
|
||||
@@ -24,7 +24,7 @@ describe "Admin Budgets", :admin do
|
||||
visit admin_budgets_path
|
||||
select "Français", from: "Language:"
|
||||
|
||||
click_link "Bulletins de l’admin"
|
||||
click_button "Bulletins de l’admin"
|
||||
|
||||
expect(page).to have_current_path(/admin\/polls\/\d+/)
|
||||
expect(page).to have_content("Budget pour le changement climatique")
|
||||
|
||||
@@ -82,7 +82,7 @@ describe "SDG homepage configuration" do
|
||||
visit sdg_management_homepage_path
|
||||
|
||||
within ".sdg-header" do
|
||||
accept_confirm { click_link "Delete" }
|
||||
accept_confirm { click_button "Delete" }
|
||||
end
|
||||
|
||||
expect(page).not_to have_content "SDG Header"
|
||||
|
||||
@@ -16,7 +16,7 @@ describe "Local Targets" do
|
||||
expect(page).to have_title "SDG content - Local Targets"
|
||||
within("table tr", text: "Affordable food") do
|
||||
expect(page).to have_link "Edit"
|
||||
expect(page).to have_link "Delete"
|
||||
expect(page).to have_button "Delete"
|
||||
end
|
||||
expect(page).to have_link "Create local target"
|
||||
end
|
||||
@@ -91,7 +91,7 @@ describe "Local Targets" do
|
||||
create(:sdg_local_target, code: "1.1.1")
|
||||
visit sdg_management_local_targets_path
|
||||
|
||||
accept_confirm { click_link "Delete" }
|
||||
accept_confirm { click_button "Delete" }
|
||||
|
||||
expect(page).to have_content("Local target deleted successfully")
|
||||
expect(page).not_to have_content("1.1.1")
|
||||
|
||||
Reference in New Issue
Block a user