baarkerlounger
3 years ago
7 changed files with 73 additions and 8 deletions
@ -0,0 +1,7 @@ |
|||||||
|
class AddPostcodeToCaseLogs < ActiveRecord::Migration[6.1] |
||||||
|
def change |
||||||
|
change_table :case_logs, bulk: true do |t| |
||||||
|
t.column :postcode, :string |
||||||
|
end |
||||||
|
end |
||||||
|
end |
@ -1,6 +1,15 @@ |
|||||||
FactoryBot.define do |
FactoryBot.define do |
||||||
factory :case_log do |
factory :case_log do |
||||||
id { 342_351 } |
sequence(:id) { |i| i } |
||||||
|
trait :in_progress do |
||||||
status { 0 } |
status { 0 } |
||||||
|
tenant_code { "TH356" } |
||||||
|
postcode { "SW2 6HI" } |
||||||
|
end |
||||||
|
trait :submitted do |
||||||
|
status { 1 } |
||||||
|
tenant_code { "BZ737" } |
||||||
|
postcode { "NW1 7TY" } |
||||||
|
end |
||||||
end |
end |
||||||
end |
end |
||||||
|
@ -0,0 +1,42 @@ |
|||||||
|
require "rails_helper" |
||||||
|
RSpec.describe "case_logs/index" do |
||||||
|
let(:in_progress_log) { FactoryBot.create(:case_log, :in_progress) } |
||||||
|
let(:submitted_log) { FactoryBot.create(:case_log, :submitted) } |
||||||
|
|
||||||
|
context 'given an in progress log list' do |
||||||
|
it 'renders a table for in progress logs only' do |
||||||
|
assign(:in_progress_case_logs, [in_progress_log]) |
||||||
|
assign(:submitted_case_logs, []) |
||||||
|
render |
||||||
|
expect(rendered).to match(/<table class="govuk-table">/) |
||||||
|
expect(rendered).to match(/Logs you need to complete/) |
||||||
|
expect(rendered).not_to match(/Logs you've submitted/) |
||||||
|
expect(rendered).to match(in_progress_log.tenant_code) |
||||||
|
expect(rendered).to match(in_progress_log.postcode) |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
context 'given a submitted log list' do |
||||||
|
it 'renders a table for in progress logs only' do |
||||||
|
assign(:in_progress_case_logs, []) |
||||||
|
assign(:submitted_case_logs, [submitted_log]) |
||||||
|
render |
||||||
|
expect(rendered).to match(/<table class="govuk-table">/) |
||||||
|
expect(rendered).to match(/Logs you've submitted/) |
||||||
|
expect(rendered).not_to match(/Logs you need to complete/) |
||||||
|
expect(rendered).to match(submitted_log.tenant_code) |
||||||
|
expect(rendered).to match(submitted_log.postcode) |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
context 'given a submitted log list and an in_progress log list' do |
||||||
|
it 'renders two tables, one for each status' do |
||||||
|
assign(:in_progress_case_logs, [in_progress_log]) |
||||||
|
assign(:submitted_case_logs, [submitted_log]) |
||||||
|
render |
||||||
|
expect(rendered).to match(/<table class="govuk-table">/) |
||||||
|
expect(rendered).to match(/Logs you've submitted/) |
||||||
|
expect(rendered).to match(/Logs you need to complete/) |
||||||
|
end |
||||||
|
end |
||||||
|
end |
Loading…
Reference in new issue