Skip to content

Commit 701fff9

Browse files
Add nr_cut_off_date and type to bin/mavis teams list
This improves the CLI commands output, and makes it easier to debug potential issues arising in relation to national reporting teams.
1 parent 671e705 commit 701fff9

3 files changed

Lines changed: 38 additions & 4 deletions

File tree

app/lib/mavis_cli/teams/list.rb

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,24 @@ def call(ods_code: nil)
2626

2727
rows =
2828
teams.find_each.map do |team|
29-
team.slice(:id, :name, :workgroup).merge(
29+
team.slice(:id, :name, :workgroup, :type).merge(
3030
ods_code: team.organisation.ods_code,
31-
programmes: team.programmes.map(&:name).join(", ")
31+
programmes: team.programmes.map(&:name).join(", "),
32+
nr_cut_off_date: team.national_reporting_cut_off_date
3233
)
3334
end
3435

3536
puts TableTennis.new(
3637
rows,
37-
columns: %i[id name ods_code workgroup programmes],
38+
columns: %i[
39+
id
40+
name
41+
type
42+
ods_code
43+
workgroup
44+
programmes
45+
nr_cut_off_date
46+
],
3847
zebra: true
3948
)
4049
end

spec/features/cli_teams_list_spec.rb

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,18 @@ def given_a_couple_organisations_exist
2323
end
2424

2525
def and_there_are_teams_in_the_organisations
26-
@programme = Programme.sample
26+
@programme = Programme.menacwy
2727
@team1 =
2828
create(:team, organisation: @organisation1, programmes: [@programme])
2929
@team2 =
3030
create(:team, organisation: @organisation2, programmes: [@programme])
31+
@team_national_reporting =
32+
create(
33+
:team,
34+
:national_reporting,
35+
national_reporting_cut_off_date: 1.day.ago
36+
)
37+
@team_support = create(:team, :support)
3138
end
3239

3340
def when_i_run_the_list_teams_command
@@ -46,11 +53,24 @@ def when_i_run_the_list_teams_command_with_an_ods_code
4653

4754
def then_i_should_see_the_list_of_teams
4855
expect(@output).to include(@team1.name)
56+
expect(@output).to include(@team1.type)
4957
expect(@output).to include(@organisation1.ods_code)
5058
expect(@output).to include(@team1.workgroup)
59+
5160
expect(@output).to include(@team2.name)
61+
expect(@output).to include(@team2.type)
5262
expect(@output).to include(@organisation2.ods_code)
5363
expect(@output).to include(@team2.workgroup)
64+
65+
expect(@output).to include(@team_national_reporting.name)
66+
expect(@output).to include(@team_national_reporting.type)
67+
expect(@output).to include(
68+
@team_national_reporting.national_reporting_cut_off_date.to_s
69+
)
70+
71+
expect(@output).to include(@team_support.name)
72+
expect(@output).to include(@team_support.type)
73+
5474
expect(@output).to include(@programme.name).twice
5575
end
5676

spec/support/capture_output.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ def capture_output(input: nil)
1616
end
1717
stub_const("ProgressBar::Output::DEFAULT_OUTPUT_STREAM", output)
1818

19+
# Pretend that the terminal window is wide, so table cells aren't truncated.
20+
allow(TableTennis::Util::Console).to receive(:winsize).and_return(
21+
[48, 220]
22+
)
23+
1924
yield
2025

2126
output.string

0 commit comments

Comments
 (0)