From 53d2c10e1d7ecf410df92a1973922feb6987798e Mon Sep 17 00:00:00 2001 From: Marcel Horlings Date: Sat, 14 Jan 2017 11:06:53 +0100 Subject: [PATCH] fix hound issues --- app/helpers/application_helper.rb | 5 +++++ app/views/billables/_hours_entries.html.haml | 8 ++++---- app/views/billables/_mileages_entries.html.haml | 4 ++-- .../user_visits_billable_entries_overview_spec.rb | 9 ++++++--- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index c7ec8432..9875204b 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -77,4 +77,9 @@ def easter? holiday = Holidays.on(Date.today, :nl) holiday[0][:name] == "Pasen" if holiday.any? end + + def billable_hours_of(project) + Hour.includes(:category, :user, :project). + where(project: project, billed: false) + end end diff --git a/app/views/billables/_hours_entries.html.haml b/app/views/billables/_hours_entries.html.haml index f3d80418..d9f6eac1 100644 --- a/app/views/billables/_hours_entries.html.haml +++ b/app/views/billables/_hours_entries.html.haml @@ -8,11 +8,11 @@ %th= t("billables.table.category") %th= t("billables.table.hours") %th= t("billables.table.user") - - Hour.includes(:category, :user, :project).where(project: project, billed: false).each do |hour| + - billable_hours_of(project).each do |hour| %tr.info-row - %td=billable_entry_checkbox(hour, "hours") - %td=I18n.l (hour.date) - %td=hour.category.name + %td= billable_entry_checkbox(hour, "hours") + %td= I18n.l (hour.date) + %td= hour.category.name %td.center= hour.value %td = link_to hour.user do diff --git a/app/views/billables/_mileages_entries.html.haml b/app/views/billables/_mileages_entries.html.haml index ee44d777..a1e9a49c 100644 --- a/app/views/billables/_mileages_entries.html.haml +++ b/app/views/billables/_mileages_entries.html.haml @@ -10,8 +10,8 @@ %th= t("billables.table.user") - project.mileages.where(billed: false).each do |mileage| %tr.info-row - %td=billable_entry_checkbox(mileage, "mileages") - %td=I18n.l (mileage.date) + %td= billable_entry_checkbox(mileage, "mileages") + %td= I18n.l (mileage.date) %td %td.center= mileage.value %td diff --git a/spec/features/user_visits_billable_entries_overview_spec.rb b/spec/features/user_visits_billable_entries_overview_spec.rb index cd44095e..d7b8839b 100644 --- a/spec/features/user_visits_billable_entries_overview_spec.rb +++ b/spec/features/user_visits_billable_entries_overview_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + feature "User manages billables" do let(:subdomain) { generate(:subdomain) } @@ -11,7 +13,7 @@ client = create(:client) project = create(:project, client: client, billable: true) project2 = create(:project, client: client, billable: false) - entry = create(:hour, project: project, billed: false) + create(:hour, project: project, billed: false) visit billables_url(subdomain: subdomain) @@ -24,7 +26,7 @@ client = create(:client) project = create(:project, client: client, billable: true) project2 = create(:project, client: client, billable: true) - entry = create(:hour, project: project, billed: false) + create(:hour, project: project, billed: false) visit billables_url(subdomain: subdomain) @@ -54,7 +56,8 @@ project = create(:project, client: client, billable: true) user = create(:user) entry = create( - :mileage, project: project, user: user, value: 2, billed: false) + :mileage, project: project, user: user, value: 2, billed: false + ) visit billables_url(subdomain: subdomain)