Skip to content

Commit

Permalink
Fix specs / Modify views
Browse files Browse the repository at this point in the history
  • Loading branch information
JoonasAapro committed Dec 9, 2024
1 parent ae449a5 commit d06d2db
Show file tree
Hide file tree
Showing 24 changed files with 53 additions and 76 deletions.
1 change: 0 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ end
desc "Generates a dummy app for testing"
task test_app: "decidim:generate_external_test_app" do
ENV["RAILS_ENV"] = "test"
fix_babel_config("spec/decidim_dummy_app")
install_module("spec/decidim_dummy_app")
end

Expand Down
2 changes: 1 addition & 1 deletion app/cells/decidim/ideas/idea_g_cell.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def body
end

def category
translated_attribute(model.category.name) if has_category?
decidim_sanitize translated_attribute(model.category.name) if has_category?
end

def full_category
Expand Down
1 change: 1 addition & 0 deletions app/controllers/decidim/ideas/ideas_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class IdeasController < Decidim::Ideas::ApplicationController

include Decidim::ApplicationHelper
include FormFactory
include Flaggable
include FilterResource
include Decidim::Ideas::Orderable
include Paginable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def settings_attribute_input(form, attribute, name, i18n_scope, options = {})
end
when :idea_area_scope_coordinates
component_id = @component.new_record? ? "new" : @component.id
visibility_class = @component.settings.geocoding_enabled ? "" : "hide"
visibility_class = @component.settings.geocoding_enabled ? "" : "hidden"
value = area_scopes_coordinates(@component)
label = t(name, scope: i18n_scope)
coordinates_element = render(
Expand Down
4 changes: 2 additions & 2 deletions app/helpers/decidim/ideas/admin/ideas_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,12 @@ def ideas_admin_filter_applied_filters
def icon_with_link_to_idea(idea)
icon, tooltip = if allowed_to?(:create, :idea_answer, idea: idea) && !idea.emendation?
[
"comment-square",
"question-answer-line",
t(:answer_idea, scope: "decidim.ideas.actions")
]
else
[
"info",
"information-line",
t(:show, scope: "decidim.ideas.actions")
]
end
Expand Down
4 changes: 2 additions & 2 deletions app/packs/src/decidim/ideas/admin/component_settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ $(() => {

$("input[name='component[settings][geocoding_enabled]']").on("change", (ev) => {
if ($(ev.target).is(":checked")) {
$coordinatesElement.removeClass("hide");
$coordinatesElement.removeClass("hidden");
} else {
$coordinatesElement.addClass("hide");
$coordinatesElement.addClass("hidden");
}
});

Expand Down
14 changes: 7 additions & 7 deletions app/packs/src/decidim/ideas/admin/ideas.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,32 +33,32 @@ $(document).ready(function () {

let showBulkActionsButton = function() {
if (selectedIdeasCount() > 0) {
$("#js-bulk-actions-button").removeClass("hide");
$("#js-bulk-actions-button").removeClass("hidden");
}
}

window.hideBulkActionsButton = function(force = false) {
if (selectedIdeasCount() === 0 || force === true) {
$("#js-bulk-actions-button").addClass("hide");
$("#js-bulk-actions-button").addClass("hidden");
$("#js-bulk-actions-dropdown").removeClass("is-open");
}
}

window.showOtherActionsButtons = function() {
$("#js-other-actions-wrapper").removeClass("hide");
$("#js-other-actions-wrapper").removeClass("hidden");
}

window.hideOtherActionsButtons = function() {
$("#js-other-actions-wrapper").addClass("hide");
$("#js-other-actions-wrapper").addClass("hidden");
}

window.hideBulkActionForms = function() {
$(".js-bulk-action-form").addClass("hide");
$(".js-bulk-action-form").addClass("hidden");
}

if ($(".js-bulk-action-form").length) {
window.hideBulkActionForms();
$("#js-bulk-actions-button").addClass("hide");
$("#js-bulk-actions-button").addClass("hidden");

$("#js-bulk-actions-dropdown ul li button").click(function(ev) {
ev.preventDefault();
Expand All @@ -69,7 +69,7 @@ $(document).ready(function () {
$(".layout-content > .callout-wrapper").html("");
})

$(`#js-${action}-actions`).removeClass("hide");
$(`#js-${action}-actions`).removeClass("hidden");
window.hideBulkActionsButton(true);
window.hideOtherActionsButtons();
}
Expand Down
6 changes: 3 additions & 3 deletions app/packs/src/decidim/ideas/admin/ideas_form.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
const subcategorySelects = {};
$sections.each((_i, el) => {
const $sub = $(el);
$sub.removeClass("hide");
$sub.removeClass("hidden");
subcategorySelects[$sub.data("parent")] = $sub;
});

Expand All @@ -28,9 +28,9 @@

$geocodingToggle.on("change.decidim.ideas", () => {
if ($geocodingToggle.is(":checked")) {
$(".geocoding-field").addClass("hide");
$(".geocoding-field").addClass("hidden");
} else {
$(".geocoding-field").removeClass("hide");
$(".geocoding-field").removeClass("hidden");
}
}).trigger("change.decidim.ideas");
};
Expand Down
2 changes: 1 addition & 1 deletion app/packs/src/decidim/ideas/idea_form.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ import "src/decidim/ideas/info_modals";
const subcategorySelects = {};
$sections.each((_i, el) => {
const $sub = $(el);
$sub.removeClass("hide");
$sub.removeClass("hidden");
subcategorySelects[$sub.data("parent")] = $sub;
});

Expand Down
2 changes: 1 addition & 1 deletion app/views/decidim/ideas/admin/ideas/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
<% @form.top_categories.each do |category| %>
<% next if category.subcategories.blank? %>

<div class="subcategories hide" data-parent="<%= category.id %>">
<div class="subcategories hidden" data-parent="<%= category.id %>">
<div class="row column">
<%= form.categories_select :sub_category_id, category.subcategories, { disable_parents: false, prompt: t(".select_a_sub_category") }, id: "sub_category_id_for_#{category.id}" %>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
<div id="js-scope-change-ideas-actions" class="hide js-bulk-action-form">
<div id="js-scope-change-ideas-actions" class="hidden js-bulk-action-form">
<%= form_tag(update_area_scope_ideas_path, method: :post, remote: true, id: "js-form-scope-change-ideas", class: "flex--cc flex-gap--1") do %>
<div class="checkboxes hide">
<div class="checkboxes hidden">
<% ideas.each do |idea| %>
<%= check_box_tag "idea_ids[]", idea.id, false, class: "js-check-all-idea js-idea-id-#{idea.id}" %>
<% end %>
</div>

<%= scopes_picker_tag(
:area_scope_id,
current_component.settings.area_scope_parent_id,
field: t("models.idea.fields.area_scope", scope: "decidim.ideas")
) %>
<%= scopes_select_tag(:area_scope_id, options: { selected: current_component.settings.area_scope_parent_id }) %>

<%= submit_tag(
t("decidim.ideas.admin.ideas.index.update_scope_button"),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div id="js-bulk-actions-wrapper">
<button
id="js-bulk-actions-button"
class="button button--nomargin tiny success light dropdown hide"
class="button button--nomargin tiny success light dropdown hidden"
type="button"
data-toggle="js-bulk-actions-dropdown">
<%= t("decidim.ideas.admin.ideas.index.actions") %>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div id="js-merge-ideas-actions" class="hide js-bulk-action-form">
<div id="js-merge-ideas-actions" class="hidden js-bulk-action-form">
<%= form_tag(ideas_merge_path, method: :post, id: "js-form-merge-ideas", class: "flex--cc flex-gap--1") do %>
<div class="checkboxes hide">
<div class="checkboxes hidden">
<% ideas.each do |idea| %>
<%= check_box_tag "idea_ids[]", idea.id, false, class: "js-check-all-idea js-idea-id-#{idea.id}" %>
<% end %>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div id="js-publish-answers-actions" class="hide js-bulk-action-form">
<div id="js-publish-answers-actions" class="hidden js-bulk-action-form">
<%= form_tag(publish_answers_ideas_path, method: :post, remote: true, id: "js-form-publish-answers", class: "flex--cc flex-gap--1") do %>
<div class="checkboxes hide">
<div class="checkboxes hidden">
<% ideas.each do |idea| %>
<%= check_box_tag "idea_ids[]", idea.id, false, class: "js-check-all-idea js-idea-id-#{idea.id}" %>
<% end %>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div id="js-recategorize-ideas-actions" class="hide js-bulk-action-form">
<div id="js-recategorize-ideas-actions" class="hidden js-bulk-action-form">
<%= form_tag(update_category_ideas_path, method: :post, remote: true, id: "js-form-recategorize-ideas", class: "flex--cc flex-gap--1") do %>
<div class="checkboxes hide">
<div class="checkboxes hidden">
<% ideas.each do |idea| %>
<%= check_box_tag "idea_ids[]", idea.id, false, class: "js-check-all-idea js-idea-id-#{idea.id}" %>
<% end %>
Expand Down
20 changes: 0 additions & 20 deletions app/views/decidim/ideas/ideas/_flag_modal.html.erb

This file was deleted.

4 changes: 2 additions & 2 deletions app/views/decidim/ideas/ideas/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
<div class="field" id="address_input">
<div class="input-group">
<span class="input-group-label">
<%= icon "map-marker", aria_hidden: true %>
<%= icon "map-pin-line", aria_hidden: true %>
</span>
<%= form.geocoding_field :address, label: false, class: "input-group-field", data: {
"coordinates-url": geocoding_path,
Expand Down Expand Up @@ -149,7 +149,7 @@
<% @form.top_categories.each do |category| %>
<% next if category.subcategories.blank? %>

<div class="subcategories hide" data-parent="<%= category.id %>">
<div class="subcategories hidden" data-parent="<%= category.id %>">
<%= form.plain_label :sub_category_id %>

<div class="row">
Expand Down
4 changes: 2 additions & 2 deletions app/views/decidim/ideas/ideas/_idea_aside.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<% if show_actions %>
<section class="layout-aside__section actions__secondary">
<%= cell("decidim/favorites/favorite_button", idea, button_class: "link text-secondary", disable_tooltip: true) %>
<%= cell("decidim/favorites/favorite_button", idea, button_class: "link-text text-secondary", disable_tooltip: true) %>
</section>
<% end %>

Expand Down Expand Up @@ -28,7 +28,7 @@
</section>

<section class="layout-aside__section actions__secondary">
<%= cell "decidim/report_button", idea, only_button: true%>
<%= cell "decidim/report_button", idea %>
</section>
<% end %>

Expand Down
2 changes: 1 addition & 1 deletion spec/cells/decidim/ideas/idea_g_cell_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require "spec_helper"

module Decidim::Ideas
describe IdeaMCell, type: :cell do
describe IdeaGCell, type: :cell do
controller Decidim::Ideas::IdeasController

subject { cell_html }
Expand Down
2 changes: 1 addition & 1 deletion spec/system/admin/admin_creates_idea_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@

before do
visit current_path
find(".icon--pencil").click
find(".action-icon--edit-idea").click
end

it "updates the idea" do
Expand Down
15 changes: 6 additions & 9 deletions spec/system/admin/admin_filters_ideas_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@
let!(:idea5) { create(:idea, :withdrawn, title: idea5_title, component: component) }

before do
within ".fcell.filter" do
find(".dropdown.button").hover
end
click_on "Filter"
find("a", text: "State").hover
end

Expand Down Expand Up @@ -73,8 +71,9 @@

before do
visit current_path
within ".fcell.filter" do
find(".dropdown.button").hover
click_on "Filter"

within ".card-section" do
find("a", text: "Area").hover
end
end
Expand All @@ -93,10 +92,8 @@

before do
visit current_path
within ".fcell.filter" do
find(".dropdown.button").hover
find("a", text: "Category").hover
end
click_on "Filter"
find("a", text: "Category").hover
end

it "filters by category" do
Expand Down
6 changes: 3 additions & 3 deletions spec/system/admin/admin_manages_component_settings_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def components_path(component)
let(:coordinates) { "60.1699,24.9384" }

before do
find(".icon--cog", match: :first).click
find(".action-icon--configure", match: :first).click
end

it "updates component's settings" do
Expand All @@ -60,8 +60,8 @@ def components_path(component)
end

describe "delete" do
it "delets component" do
find(".icon--circle-x").click
it "deletes component" do
find(".action-icon--remove").click
expect(page).to have_content("Component deleted successfully")
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/system/admin/admin_manages_ideas_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@
end

it "unreports" do
find(".icon--action-undo").click
find(".action-icon--unreport").click
expect(page).to have_content("Resource successfully unreported")
end

it "hides" do
find(".icon--eye").click
find(".action-icon--hide").click
expect(page).to have_content("Resource successfully hidden")
expect(Decidim::Ideas::Idea.find(idea.id).hidden?).to be(true)
end
Expand Down
10 changes: 7 additions & 3 deletions spec/system/browse_ideas_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,14 @@

it "creates report" do
click_link idea.title
click_button "Report idea"
click_button "Report"
choose "report[reason]", option: reason
fill_in "report[details]", with: report_body
click_button "Report"

within "#flagModal-content" do
click_button "Report"
end

expect(page).to have_content("The report has been created successfully and it will be reviewed by an admin")
expect(Decidim::Report.last.details).to eq(report_body)
expect(Decidim::Report.last.reason).to eq(reason)
Expand All @@ -115,7 +119,7 @@
it "follows link" do
click_link idea2.title
fill_in "add-comment-Idea-#{idea2.id}", with: add_comment
click_button "Send"
click_button "Publish comment"
click_link idea3_title
expect(page).to have_content(idea3_body)
expect(page).to have_content(idea3.category.name["en"])
Expand Down

0 comments on commit d06d2db

Please sign in to comment.