<% if proposed_action.proposals.where(id: proposal.id).any? %>
- <%= link_to unexecute_proposal_dashboard_action_path(proposal, proposed_action),
- id: "#{dom_id(proposed_action)}_unexecute",
- method: :post,
- class: "checked-link" do %>
-
+ <%= button_to unexecute_proposal_dashboard_action_path(proposal, proposed_action),
+ class: "checked-link" do %>
+
+ <%= t("dashboard.recommended_actions.unexecute", name: proposed_action.title) %>
+
<% end %>
<% else %>
- <%= link_to execute_proposal_dashboard_action_path(proposal, proposed_action),
- id: "#{dom_id(proposed_action)}_execute",
- method: :post,
- class: "unchecked-link" do %>
-
+ <%= button_to execute_proposal_dashboard_action_path(proposal, proposed_action),
+ class: "unchecked-link" do %>
+
+ <%= t("dashboard.recommended_actions.execute", name: proposed_action.title) %>
+
<% end %>
<% end %>
diff --git a/app/views/legislation/annotations/_annotation_link.html.erb b/app/views/legislation/annotations/_annotation_link.html.erb
deleted file mode 100644
index b047f52cb..000000000
--- a/app/views/legislation/annotations/_annotation_link.html.erb
+++ /dev/null
@@ -1,3 +0,0 @@
-<%= link_to legislation_process_draft_version_annotation_path(annotation.draft_version.process, annotation.draft_version, annotation, sub_annotation_ids: "") do %>
-
-<% end %>
diff --git a/app/views/legislation/annotations/_comment_header.html.erb b/app/views/legislation/annotations/_comment_header.html.erb
index f767cf7a3..80d55cdb9 100644
--- a/app/views/legislation/annotations/_comment_header.html.erb
+++ b/app/views/legislation/annotations/_comment_header.html.erb
@@ -1,5 +1,8 @@
-<%= render Shared::CommentsCountComponent.new(annotation.comments.roots.count) %>
-
- <%= render "annotation_link", annotation: annotation %>
+ <%= render Shared::CommentsCountComponent.new(
+ annotation.comments.roots.count,
+ url: legislation_process_draft_version_annotation_path(
+ annotation.draft_version.process, annotation.draft_version, annotation, sub_annotation_ids: ""
+ )
+ ) %>
diff --git a/app/views/legislation/annotations/comments.js.erb b/app/views/legislation/annotations/comments.js.erb
index 1e0985217..46550b8cd 100644
--- a/app/views/legislation/annotations/comments.js.erb
+++ b/app/views/legislation/annotations/comments.js.erb
@@ -14,11 +14,11 @@ if ($(".comment").length == 0) {
$("#annotation-link a").attr("href", new_annotation_link)
- var current_comment_text = $(".comments-count").text()
+ var current_comment_text = $("#annotation-link a").text()
var current_comment_count = current_comment_text.match(/\d+/)[0]
var new_comment_count = parseInt(current_comment_count) + parseInt(<%= @annotation.comments.roots.count %>)
var new_comment_count_text = current_comment_text.replace(/(\d+)/, new_comment_count);
- $(".comments-count").text(new_comment_count_text)
+ $("#annotation-link a").text(new_comment_count_text)
}
<%= render "comments_box_form", comment: @comment, annotation: @annotation %>
diff --git a/config/locales/en/general.yml b/config/locales/en/general.yml
index 4ee75c137..163091a05 100644
--- a/config/locales/en/general.yml
+++ b/config/locales/en/general.yml
@@ -475,6 +475,8 @@ en:
see_proposed_actions: Check out recommended actions
hide_proposed_actions: Hide recommended actions
pending_title: Pending
+ execute: "Mark %{name} as done"
+ unexecute: "Unmark %{name} as done"
show_description: Show description
without_pending_actions: No recommended actions pending
done_title: Done
diff --git a/config/locales/en/management.yml b/config/locales/en/management.yml
index 3cf7506a3..06e9ab967 100644
--- a/config/locales/en/management.yml
+++ b/config/locales/en/management.yml
@@ -18,6 +18,7 @@ en:
reseted: Password reseted successfully
random: Generate random password
save: Save password
+ show: Show password
print: Print password
print_help: You will be able to print the password when it is saved.
account_info:
diff --git a/config/locales/es/general.yml b/config/locales/es/general.yml
index 458f437a8..1b803c460 100644
--- a/config/locales/es/general.yml
+++ b/config/locales/es/general.yml
@@ -475,6 +475,8 @@ es:
see_proposed_actions: Ver todas las acciones recomendadas
hide_proposed_actions: Ocultar acciones recomendadas
pending_title: Pendientes
+ execute: "Marcar la acción %{name} como realizada"
+ unexecute: "Desmarcar la acción %{name} como realizada"
show_description: Mostrar descripción
without_pending_actions: No hay acciones recomendadas pendientes
done_title: Realizadas
diff --git a/config/locales/es/management.yml b/config/locales/es/management.yml
index 895268f16..e7510f6cc 100644
--- a/config/locales/es/management.yml
+++ b/config/locales/es/management.yml
@@ -18,6 +18,7 @@ es:
reseted: Contraseña restablecida correctamente
random: Generar contraseña aleatoria
save: Guardar contraseña
+ show: Mostrar contraseña
print: Imprimir contraseña
print_help: Podrás imprimir la contraseña cuando se haya guardado.
account_info:
diff --git a/spec/components/shared/banner_component_spec.rb b/spec/components/shared/banner_component_spec.rb
index 6d2512373..403a45e9d 100644
--- a/spec/components/shared/banner_component_spec.rb
+++ b/spec/components/shared/banner_component_spec.rb
@@ -31,6 +31,14 @@ describe Shared::BannerComponent do
expect(page).not_to have_content "Proposal banner"
end
+ it "does not render an empty banner" do
+ banner = build(:banner, title: "", description: "")
+
+ render_inline Shared::BannerComponent.new(banner)
+
+ expect(page).not_to be_rendered
+ end
+
context "several banners available in the same section" do
before do
create(:banner,
diff --git a/spec/models/legislation/process_spec.rb b/spec/models/legislation/process_spec.rb
index 5b62b98f4..511e5aa62 100644
--- a/spec/models/legislation/process_spec.rb
+++ b/spec/models/legislation/process_spec.rb
@@ -154,6 +154,21 @@ describe Legislation::Process do
expect(proposals_disabled).to be_valid
expect(allegations_disabled).to be_valid
end
+
+ it "is invalid if result publication is enabled but result_publication_date is not present" do
+ process = build(:legislation_process, result_publication_enabled: true, result_publication_date: "")
+
+ expect(process).not_to be_valid
+ expect(process.errors.messages[:result_publication_date]).to include("can't be blank")
+ end
+
+ it "is valid if result publication is enabled and result_publication_date is present" do
+ process = build(:legislation_process,
+ result_publication_enabled: true,
+ result_publication_date: Date.tomorrow)
+
+ expect(process).to be_valid
+ end
end
describe "date ranges validations" do
diff --git a/spec/system/comments/legislation_annotations_spec.rb b/spec/system/comments/legislation_annotations_spec.rb
index 22d169430..d547d282e 100644
--- a/spec/system/comments/legislation_annotations_spec.rb
+++ b/spec/system/comments/legislation_annotations_spec.rb
@@ -35,13 +35,12 @@ describe "Commenting legislation annotations" do
end
scenario "View comments of annotations in an included range" do
- within("#annotation-link") do
- find(".icon-expand").click
- end
+ click_link "2 comment"
- expect(page).to have_css(".comment", count: 2)
- expect(page).to have_content("my annotation")
- expect(page).to have_content("my other annotation")
+ expect(page).to have_content "Comments about"
+ expect(page).to have_css ".comment", count: 2
+ expect(page).to have_content "my annotation"
+ expect(page).to have_content "my other annotation"
end
scenario "Reply on a single annotation thread and display it in the merged annotation thread" do
@@ -70,20 +69,16 @@ describe "Commenting legislation annotations" do
expect(page).to have_content "my other annotation"
end
- within("#annotation-link") do
- find(".icon-expand").click
- end
+ click_link "2 comment"
- expect(page).to have_css(".comment", count: 3)
- expect(page).to have_content("my annotation")
- expect(page).to have_content("my other annotation")
- expect(page).to have_content("replying in single annotation thread")
+ expect(page).to have_css ".comment", count: 3
+ expect(page).to have_content "my annotation"
+ expect(page).to have_content "my other annotation"
+ expect(page).to have_content "replying in single annotation thread"
end
scenario "Reply on a multiple annotation thread and display it in the single annotation thread" do
- within("#annotation-link") do
- find(".icon-expand").click
- end
+ click_link "2 comment"
within("#comment_#{comment2.id}") do
click_link "Reply"
diff --git a/spec/system/dashboard/dashboard_spec.rb b/spec/system/dashboard/dashboard_spec.rb
index aaf7cfb28..b318c1dc7 100644
--- a/spec/system/dashboard/dashboard_spec.rb
+++ b/spec/system/dashboard/dashboard_spec.rb
@@ -47,14 +47,6 @@ describe "Proposal's dashboard" do
end
end
- scenario "Dashboard progress show proposed actions" do
- action = create(:dashboard_action, :proposed_action, :active)
-
- visit progress_proposal_dashboard_path(proposal)
-
- expect(page).to have_content(action.title)
- end
-
scenario "Dashboard progress show proposed actions truncated description" do
action = create(:dashboard_action, :proposed_action, :active, description: "One short action")
action_long = create(:dashboard_action, :proposed_action, :active,
@@ -100,45 +92,42 @@ describe "Proposal's dashboard" do
end
scenario "Dashboard progress display proposed_action pending on his section" do
- action = create(:dashboard_action, :proposed_action, :active)
+ create(:dashboard_action, :proposed_action, :active, title: "Expand!")
visit progress_proposal_dashboard_path(proposal)
within "#proposed_actions_pending" do
- expect(page).to have_content(action.title)
+ expect(page).to have_content "Expand!"
end
- end
- scenario "Dashboard progress display proposed_action done on his section" do
- action = create(:dashboard_action, :proposed_action, :active)
-
- visit progress_proposal_dashboard_path(proposal)
- find(:css, "#dashboard_action_#{action.id}_execute").click
+ click_button "Mark Expand! as done"
within "#proposed_actions_done" do
- expect(page).to have_content(action.title)
+ expect(page).to have_content "Expand!"
end
- end
- scenario "Dashboard progress can execute proposed action" do
- action = create(:dashboard_action, :proposed_action, :active)
-
- visit progress_proposal_dashboard_path(proposal)
- expect(page).to have_content(action.title)
-
- find(:css, "#dashboard_action_#{action.id}_execute").click
- expect(page).not_to have_css "#dashboard_action_#{action.id}_execute"
+ expect(page).not_to have_button "Mark Expand! as done"
+ expect(page).to have_button "Unmark Expand! as done"
end
scenario "Dashboard progress can unexecute proposed action" do
- action = create(:dashboard_action, :proposed_action, :active)
+ action = create(:dashboard_action, :proposed_action, :active, title: "Reinforce!")
create(:dashboard_executed_action, proposal: proposal, action: action)
visit progress_proposal_dashboard_path(proposal)
- expect(page).to have_content(action.title)
- find(:css, "#dashboard_action_#{action.id}_unexecute").click
- expect(page).to have_css "#dashboard_action_#{action.id}_execute"
+ within "#proposed_actions_done" do
+ expect(page).to have_content "Reinforce!"
+ end
+
+ click_button "Unmark Reinforce! as done"
+
+ within "#proposed_actions_pending" do
+ expect(page).to have_content "Reinforce!"
+ end
+
+ expect(page).not_to have_button "Unmark Reinforce! as done"
+ expect(page).to have_button "Mark Reinforce! as done"
end
scenario "Dashboard progress dont show proposed actions with published_proposal: true" do
@@ -472,10 +461,10 @@ describe "Proposal's dashboard" do
end
scenario "On recommended actions section display proposed_action done on his section" do
- action = create(:dashboard_action, :proposed_action, :active)
+ action = create(:dashboard_action, :proposed_action, :active, title: "Make progress")
visit recommended_actions_proposal_dashboard_path(proposal.to_param)
- find(:css, "#dashboard_action_#{action.id}_execute").click
+ click_button "Mark Make progress as done"
within "#proposed_actions_done" do
expect(page).to have_content(action.title)
diff --git a/spec/system/legislation/summary_spec.rb b/spec/system/legislation/summary_spec.rb
index 36c9ffe28..a521d0827 100644
--- a/spec/system/legislation/summary_spec.rb
+++ b/spec/system/legislation/summary_spec.rb
@@ -22,6 +22,7 @@ describe "Legislation" do
scenario "empty process" do
process = create(:legislation_process, :empty,
result_publication_enabled: true,
+ result_publication_date: 1.day.ago,
end_date: Date.current - 1.day)
visit summary_legislation_process_path(process)
diff --git a/spec/system/management/account_spec.rb b/spec/system/management/account_spec.rb
index 9350137db..100c3502c 100644
--- a/spec/system/management/account_spec.rb
+++ b/spec/system/management/account_spec.rb
@@ -27,18 +27,20 @@ describe "Account" do
expect(email).to have_text "Change your password"
end
- scenario "Manager changes the password by hand (writen by them)" do
+ scenario "Manager manually writes the new password" do
user = create(:user, :level_three)
login_managed_user(user)
login_as_manager
click_link "Reset password manually"
- find(:css, "input[id$='user_password']").set("new_password")
+ fill_in "Password", with: "new_password"
click_button "Save password"
expect(page).to have_content "Password reseted successfully"
+ expect(page).to have_link "Print password", href: "javascript:window.print();"
+ expect(page).to have_css "div.for-print-only", text: "new_password", visible: :hidden
logout
@@ -57,6 +59,19 @@ describe "Account" do
new_password = find_field("user_password").value
+ expect(page).to have_field "Password", type: :password
+ expect(page).to have_css "button[aria-pressed=false]", exact_text: "Show password"
+
+ click_button "Show password"
+
+ expect(page).to have_field "Password", type: :text
+ expect(page).to have_css "button[aria-pressed=true]", exact_text: "Show password"
+
+ click_button "Show password"
+
+ expect(page).to have_field "Password", type: :password
+ expect(page).to have_css "button[aria-pressed=false]", exact_text: "Show password"
+
click_button "Save password"
expect(page).to have_content "Password reseted successfully"
@@ -68,22 +83,6 @@ describe "Account" do
expect(page).to have_content "You have been signed in successfully."
end
- scenario "The password is printed" do
- user = create(:user, :level_three)
- login_managed_user(user)
-
- login_as_manager
- click_link "Reset password manually"
-
- find(:css, "input[id$='user_password']").set("another_new_password")
-
- click_button "Save password"
-
- expect(page).to have_content "Password reseted successfully"
- expect(page).to have_link "Print password", href: "javascript:window.print();"
- expect(page).to have_css("div.for-print-only", text: "another_new_password", visible: :hidden)
- end
-
describe "When a user has not been selected" do
before do
Setting["feature.user.skip_verification"] = "true"