Skip to content

Commit

Permalink
Fix lint / Fix specs
Browse files Browse the repository at this point in the history
  • Loading branch information
JoonasAapro committed Jan 15, 2025
1 parent baaada3 commit 32f5083
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ def show
raise ActionController::RoutingError, "Not Found" unless project
end

def index; end

def default_filter_params
{
search_text_cont: "",
Expand Down
17 changes: 15 additions & 2 deletions app/packs/src/decidim/budgeting_pipeline/projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// placeHolder.style.height = `${ordersSummary.offsetHeight}px`;
// console.log(ordersSummary.offsetHeight);

document.addEventListener("scroll", (event) => {
document.addEventListener("scroll", () => {
if (window.scrollY > stickPosition.offsetTop) {
if (!ordersSummary.classList.contains("is-stuck")) {
placeHolder.style.height = `${ordersSummary.offsetHeight}px`;
Expand All @@ -27,6 +27,8 @@
if (ordersSummary.classList.contains("is-stuck")) {

Check failure on line 27 in app/packs/src/decidim/budgeting_pipeline/projects.js

View workflow job for this annotation

GitHub Actions / Lint

Unexpected if as the only statement in an else block
ordersSummary.classList.remove("is-stuck");
placeHolder.style.height = 0;
} else {
return;
}
}
});
Expand Down Expand Up @@ -70,12 +72,21 @@
window.initializeProjects = () => {
const loadingProjects = [];
document.querySelectorAll("[data-project-selector] input[type='checkbox']").forEach((el) => {

el.addEventListener("change", () => {
let requestType;

Check failure on line 77 in app/packs/src/decidim/budgeting_pipeline/projects.js

View workflow job for this annotation

GitHub Actions / Lint

Variable 'requestType' should be initialized on declaration

if (el.checked) {
requestType = "POST";
} else {
requestType = "DELETE";
}

loadingProjects.push(el.value);
document.body.classList.add("loading");
Rails.ajax({
url: el.dataset.selectUrl,
type: el.checked ? "POST" : "DELETE",
type: requestType,
success: () => {
loadingProjects.shift();
if (loadingProjects.length < 1) {
Expand Down Expand Up @@ -108,6 +119,8 @@
}

clickableArea.addEventListener("click", clickHandler);

// eslint-disable-next-line no-undef
button.addEventListener("keydown", (ev) => {
if (ev.code === "Enter" || ev.code === "Space") {
buttonClickHandler(ev);

Check failure on line 126 in app/packs/src/decidim/budgeting_pipeline/projects.js

View workflow job for this annotation

GitHub Actions / Lint

'buttonClickHandler' is not defined
Expand Down
10 changes: 5 additions & 5 deletions spec/system/explore_projects_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

it "can filter based on keywords" do
within "form.new_filter" do
find(%(input[name="filter[search_text_cont]"])).set(translated(budget1_projects.first.title))
find(%(input[name="filter[search_text_cont]"])).set(translated(budget_one_projects.first.title))
click_on "Search"
end

Expand All @@ -29,7 +29,7 @@

it "can filter based on the area" do
within "form.new_filter" do
find(%(select[name="filter[decidim_budgets_budget_id_eq]"])).find(%(option[value="#{budget1.id}"])).select_option
find(%(select[name="filter[decidim_budgets_budget_id_eq]"])).find(%(option[value="#{budget_one.id}"])).select_option
click_on "Search"
end

Expand All @@ -51,7 +51,7 @@
end

describe "show" do
let(:project) { budget1_projects.first }
let(:project) { budget_one_projects.first }

before do
visit_project(project)
Expand All @@ -69,7 +69,7 @@
let(:category) { create(:category, participatory_space: component.participatory_space, parent: parent_category) }
let(:parent_category) { create(:category, participatory_space: component.participatory_space) }

let!(:project) { create(:budgeting_pipeline_project, budget: budget1, category:) }
let!(:project) { create(:budgeting_pipeline_project, budget: budget_one, category:) }

it "displays the category and its parent category" do
expect(page).to have_content(translated(parent_category.name))
Expand All @@ -81,7 +81,7 @@
before do
component.step_settings = { component.participatory_space.active_step.id => { votes: "finished", show_votes: true, show_selected_status: true } }
component.save
budget1_projects.first.update(selected_at: Time.current)
budget_one_projects.first.update(selected_at: Time.current)
end

it "renders status selection" do
Expand Down
20 changes: 10 additions & 10 deletions spec/system/voting_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@
describe "start" do
before { login_as user, scope: :user }

let(:project1) { budget1.projects.first }
let(:project1) { budget_one.projects.first }

it "allows selecting a budget" do
visit_voting

page.scroll_to find("h2", text: "Select the area where you want to vote")

find("h2", text: translated(budget1.title)).click
find("h2", text: translated(budget_one.title)).click
find("input[name='filter[selected]']").click
find("label[for=project_selector_#{project1.id}]").click

Expand All @@ -85,7 +85,7 @@
end

describe "projects" do
let(:budget) { budget1 }
let(:budget) { budget_one }

before do
login_as user, scope: :user
Expand Down Expand Up @@ -155,11 +155,11 @@
end

describe "preview" do
let(:budget) { budget1 }
let!(:order) { create(:order, budget: budget1, user:) }
let(:budget) { budget_one }
let!(:order) { create(:order, budget: budget_one, user:) }

before do
order.projects << budget1_projects.first
order.projects << budget_one_projects.first
order.save!

login_as user, scope: :user
Expand All @@ -171,16 +171,16 @@

it "shows the vote preview page" do
expect(page).to have_content("Maximum amount of proposals to be selected in the area: 5")
expect(page).to have_content(translated(budget1_projects.first.title))
expect(page).to have_content(translated(budget_one_projects.first.title))
end
end

describe "create" do
let(:budget) { budget1 }
let!(:order) { create(:order, budget: budget1, user:) }
let(:budget) { budget_one }
let!(:order) { create(:order, budget: budget_one, user:) }

before do
order.projects << budget1_projects.first
order.projects << budget_one_projects.first
order.save!

login_as user, scope: :user
Expand Down

0 comments on commit 32f5083

Please sign in to comment.