Browse Source

Spec panel contents

pull/108/head
baarkerlounger 4 years ago
parent
commit
48d084e59d
  1. 4
      app/models/case_log.rb
  2. 12
      spec/controllers/admin/dashboard_controller_spec.rb
  3. 2
      spec/factories/case_log.rb
  4. 9
      spec/models/case_log_spec.rb

4
app/models/case_log.rb

@ -233,6 +233,10 @@ private
dynamically_not_required << "incfreq"
end
if sale_or_letting == "Letting"
dynamically_not_required << "sale_completion_date"
end
if tenancy == "Secure (including flexible)"
dynamically_not_required << "tenancylength"
end

12
spec/controllers/admin/dashboard_controller_spec.rb

@ -6,6 +6,8 @@ describe Admin::DashboardController, type: :controller do
let(:page) { Capybara::Node::Simple.new(response.body) }
let(:resource_title) { "Dashboard" }
let!(:case_log) { FactoryBot.create(:case_log, :in_progress) }
let!(:case_log_2) { FactoryBot.create(:case_log, :in_progress) }
let!(:completed_case_log) { FactoryBot.create(:case_log, :completed) }
let(:valid_session) { {} }
login_admin_user
@ -23,11 +25,17 @@ describe Admin::DashboardController, type: :controller do
end
it "returns a panel of in progress case logs" do
expect(page).to have_xpath("//div[@class='panel' and //h3[contains(., 'Total case logs in progress')]]")
panel_xpath = "//div[@class='panel' and .//h3[contains(., 'Total case logs in progress')]]"
panel_content_xpath = panel_xpath + "//div[@class='panel_contents' and .//p[contains(., 2)]]"
expect(page).to have_xpath(panel_xpath)
expect(page).to have_xpath(panel_content_xpath)
end
it "returns a panel of completed case logs" do
expect(page).to have_xpath("//div[@class='panel' and //h3[contains(., 'Total case logs completed')]]")
panel_xpath = "//div[@class='panel' and .//h3[contains(., 'Total case logs completed')]]"
panel_content_xpath = panel_xpath + "//div[@class='panel_contents' and .//p[contains(., 1)]]"
expect(page).to have_xpath(panel_xpath)
expect(page).to have_xpath(panel_content_xpath)
end
end
end

2
spec/factories/case_log.rb

@ -133,7 +133,7 @@ FactoryBot.define do
mrcyear { 2020 }
incref { 554_355 }
sale_completion_date { nil }
startdate { nil }
startdate { Time.zone.now }
armedforces { 1 }
end
created_at { Time.zone.now }

9
spec/models/case_log_spec.rb

@ -330,6 +330,7 @@ RSpec.describe Form, type: :model do
describe "status" do
let!(:empty_case_log) { FactoryBot.create(:case_log) }
let!(:in_progress_case_log) { FactoryBot.create(:case_log, :in_progress) }
let!(:completed_case_log) { FactoryBot.create(:case_log, :completed) }
it "is set to not started for an empty case log" do
expect(empty_case_log.not_started?).to be(true)
@ -337,11 +338,17 @@ RSpec.describe Form, type: :model do
expect(empty_case_log.completed?).to be(false)
end
it "is set to not started for an empty case log" do
it "is set to in progress for a started case log" do
expect(in_progress_case_log.in_progress?).to be(true)
expect(in_progress_case_log.not_started?).to be(false)
expect(in_progress_case_log.completed?).to be(false)
end
it "is set to completed for a completed case log" do
expect(completed_case_log.in_progress?).to be(false)
expect(completed_case_log.not_started?).to be(false)
expect(completed_case_log.completed?).to be(true)
end
end
describe "weekly_net_income" do

Loading…
Cancel
Save