Skip to content

Commit 82b6ca9

Browse files
authored
Merge pull request #556 from alphagov/CM-876-show-publishing-app-when-viewing-host-content
(CM-876) Show publishing app when viewing host content
2 parents 8b2cda4 + d8b786d commit 82b6ca9

5 files changed

Lines changed: 57 additions & 113 deletions

File tree

app/public/components/shared/host_editions_table_component.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ def head
3434
href: sort_link("title"),
3535
sort_direction: sort_direction("title"),
3636
},
37+
{
38+
text: "Publishing app",
39+
href: sort_link("publishing_app"),
40+
sort_direction: sort_direction("publishing_app"),
41+
},
3742
{
3843
text: "Type",
3944
href: sort_link("document_type"),
@@ -74,6 +79,9 @@ def rows
7479
def row_for_content_item(content_item)
7580
[
7681
title_row(content_item),
82+
{
83+
text: content_item.publishing_app.humanize,
84+
},
7785
{
7886
text: content_item.document_type.humanize,
7987
},

features/step_definitions/dependent_content_steps.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"title" => "Organisation #{i}",
3636
"base_path" => "/organisation/#{i}",
3737
},
38+
"publishing_app" => "publisher",
3839
}
3940
end
4041

spec/components/shared/host_editions_table_component_spec.rb

Lines changed: 46 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -67,35 +67,40 @@ def self.it_returns_unknown_user
6767
end
6868

6969
describe "table component" do
70-
it "renders embedded editions" do
70+
before do
7171
render_inline(
7272
described_class.new(
7373
caption:,
7474
host_content_items:,
7575
edition:,
7676
),
7777
)
78+
end
7879

80+
it "renders the correct headers" do
7981
expect(page).to have_css ".govuk-table__caption", text: caption
8082

8183
headers = page.find_all(".govuk-table__header")
8284

83-
expect(headers.count).to eq(6)
85+
expect(headers.count).to eq(7)
8486

8587
expect(headers[0]).to have_text "Title"
86-
expect(headers[1]).to have_text "Type"
87-
expect(headers[2]).to have_text "Instances"
88-
expect(headers[3]).to have_text "Views (30 days)"
89-
expect(headers[4]).to have_text "Lead organisation"
90-
expect(headers[5]).to have_text "Last updated"
88+
expect(headers[1]).to have_text "Publishing app"
89+
expect(headers[2]).to have_text "Type"
90+
expect(headers[3]).to have_text "Instances"
91+
expect(headers[4]).to have_text "Views (30 days)"
92+
expect(headers[5]).to have_text "Lead organisation"
93+
expect(headers[6]).to have_text "Last updated"
94+
end
9195

96+
it "renders the correct row data" do
9297
rows = page.find_all("tbody .govuk-table__row")
9398

9499
expect(rows.count).to eq(1)
95100

96101
columns = rows[0].find_all(".govuk-table__cell")
97102

98-
expect(columns.count).to eq(6)
103+
expect(columns.count).to eq(7)
99104

100105
expect(columns[0]).to have_css ".govuk-link" do |link|
101106
expect(link.text).to eq("#{host_content_item.title} (opens in new tab)")
@@ -108,14 +113,15 @@ def self.it_returns_unknown_user
108113
expect(tag.text.strip).to eq("Published")
109114
end
110115

111-
expect(columns[1]).to have_text host_content_item.document_type.humanize
112-
expect(columns[2]).to have_text "1"
113-
expect(columns[3]).to have_text "1.2m"
114-
expect(columns[4]).to have_text host_content_item.publishing_organisation["title"]
116+
expect(columns[1]).to have_text "Publisher"
117+
expect(columns[2]).to have_text host_content_item.document_type.humanize
118+
expect(columns[3]).to have_text "1"
119+
expect(columns[4]).to have_text "1.2m"
120+
expect(columns[5]).to have_text host_content_item.publishing_organisation["title"]
115121

116-
expect(columns[5]).to have_text "#{time_ago_in_words(host_content_item.last_edited_at)} ago by #{last_edited_by_editor.name}"
122+
expect(columns[6]).to have_text "#{time_ago_in_words(host_content_item.last_edited_at)} ago by #{last_edited_by_editor.name}"
117123

118-
expect(columns[5]).to have_css "a.govuk-link" do |link|
124+
expect(columns[6]).to have_css "a.govuk-link" do |link|
119125
expect(link.text).to eq(last_edited_by_editor.name)
120126
expect(link[:href]).to eq(user_path(last_edited_by_editor.uid))
121127
end
@@ -131,14 +137,6 @@ def self.it_returns_unknown_user
131137
end
132138

133139
it "presents 'Not set'" do
134-
render_inline(
135-
described_class.new(
136-
caption:,
137-
host_content_items:,
138-
edition:,
139-
),
140-
)
141-
142140
expect(page).to have_css "tbody .govuk-table__cell", text: "Not set"
143141
end
144142
end
@@ -153,14 +151,6 @@ def self.it_returns_unknown_user
153151
let(:state) { "draft" }
154152

155153
it "shows the draft tag" do
156-
render_inline(
157-
described_class.new(
158-
caption:,
159-
host_content_items:,
160-
edition:,
161-
),
162-
)
163-
164154
columns = page.find_all(".govuk-table__cell")
165155

166156
expect(columns[0]).to have_css "strong.govuk-tag" do |tag|
@@ -173,14 +163,6 @@ def self.it_returns_unknown_user
173163
let(:unique_pageviews) { nil }
174164

175165
it "displays a zero" do
176-
render_inline(
177-
described_class.new(
178-
caption:,
179-
host_content_items:,
180-
edition:,
181-
),
182-
)
183-
184166
expect(page).to have_css "tbody .govuk-table__cell", text: "0"
185167
end
186168
end
@@ -204,14 +186,6 @@ def self.it_returns_unknown_user
204186
end
205187

206188
it "Does not render a link" do
207-
render_inline(
208-
described_class.new(
209-
caption:,
210-
host_content_items:,
211-
edition:,
212-
),
213-
)
214-
215189
expect(page).to have_css "tbody" do |tbody|
216190
tbody.assert_no_selector ".govuk-link", text: host_content_item.title.to_s
217191
end
@@ -220,27 +194,12 @@ def self.it_returns_unknown_user
220194

221195
describe "sorting headers" do
222196
it "adds the table header as an anchor tag to each header" do
223-
render_inline(
224-
described_class.new(
225-
caption:,
226-
host_content_items:,
227-
edition:,
228-
),
229-
)
230-
231-
expect(page).to have_css "a.app-table__sort-link[href*='##{Shared::HostEditionsTableComponent::TABLE_ID}']", count: 6
197+
expect(page).to have_css "a.app-table__sort-link[href*='##{Shared::HostEditionsTableComponent::TABLE_ID}']", count: 7
232198
end
233199

234200
it "shows all the headers unordered by default" do
235-
render_inline(
236-
described_class.new(
237-
caption:,
238-
host_content_items:,
239-
edition:,
240-
),
241-
)
242-
243201
expect(page).to have_css "a.app-table__sort-link[href*='order=title']", text: "Title"
202+
expect(page).to have_css "a.app-table__sort-link[href*='order=publishing_app']", text: "Publishing app"
244203
expect(page).to have_css "a.app-table__sort-link[href*='order=document_type']", text: "Type"
245204
expect(page).to have_css "a.app-table__sort-link[href*='order=instances']", text: "Instances"
246205
expect(page).to have_css "a.app-table__sort-link[href*='order=unique_pageviews']", text: "Views (30 days)"
@@ -291,14 +250,6 @@ def self.it_returns_unknown_user
291250
end
292251

293252
it "does not show pagination" do
294-
render_inline(
295-
described_class.new(
296-
caption:,
297-
host_content_items:,
298-
edition:,
299-
),
300-
)
301-
302253
expect(page).not_to have_css ".govuk-pagination__list"
303254
end
304255
end
@@ -314,27 +265,11 @@ def self.it_returns_unknown_user
314265
end
315266

316267
it "adds the table header as an anchor tag to each pagination link" do
317-
render_inline(
318-
described_class.new(
319-
caption:,
320-
host_content_items:,
321-
edition:,
322-
),
323-
)
324-
325268
expect(page).to have_css "ul.govuk-pagination__list a.govuk-pagination__link[href*='##{Shared::HostEditionsTableComponent::TABLE_ID}']", count: 2
326269
expect(page).to have_css ".govuk-pagination__next a.govuk-pagination__link[href*='##{Shared::HostEditionsTableComponent::TABLE_ID}']"
327270
end
328271

329272
it "shows the first page as selected by default" do
330-
render_inline(
331-
described_class.new(
332-
caption:,
333-
host_content_items:,
334-
edition:,
335-
),
336-
)
337-
338273
expect(page).to have_css ".govuk-pagination__list"
339274
expect(page).to have_css "a.govuk-pagination__link[aria-current='page']", text: "1"
340275
end
@@ -356,53 +291,59 @@ def self.it_returns_unknown_user
356291
end
357292

358293
describe "in progress table component" do
359-
it "renders embedded editions" do
294+
before do
360295
render_inline(
361296
described_class.new(
362297
caption:,
363298
host_content_items:,
364299
edition: in_progress_edition,
365300
),
366301
)
302+
end
367303

304+
it "renders the correct headers" do
368305
expect(page).to have_css ".govuk-table__caption", text: caption
369306

370307
headers = page.find_all(".govuk-table__header")
371308

372-
expect(headers.count).to eq(7)
309+
expect(headers.count).to eq(8)
373310

374311
expect(headers[0]).to have_text "Title"
375-
expect(headers[1]).to have_text "Type"
376-
expect(headers[2]).to have_text "Instances"
377-
expect(headers[3]).to have_text "Views (30 days)"
378-
expect(headers[4]).to have_text "Lead organisation"
379-
expect(headers[5]).to have_text "Last updated"
380-
expect(headers[6]).to have_text "Preview (opens in new tab)"
312+
expect(headers[1]).to have_text "Publishing app"
313+
expect(headers[2]).to have_text "Type"
314+
expect(headers[3]).to have_text "Instances"
315+
expect(headers[4]).to have_text "Views (30 days)"
316+
expect(headers[5]).to have_text "Lead organisation"
317+
expect(headers[6]).to have_text "Last updated"
318+
expect(headers[7]).to have_text "Preview (opens in new tab)"
319+
end
381320

321+
it "renders the correct row data" do
382322
rows = page.find_all("tbody .govuk-table__row")
383323

384324
expect(rows.count).to eq(1)
385325

386326
columns = rows[0].find_all(".govuk-table__cell")
387327

388-
expect(columns.count).to eq(7)
328+
expect(columns.count).to eq(8)
389329

390330
expect(columns[0]).to have_no_css ".govuk-link"
391-
expect(columns[1]).to have_text host_content_item.document_type.humanize
392-
expect(columns[2]).to have_text "1"
393-
expect(columns[3]).to have_text "1.2m"
394-
expect(columns[4]).to have_text host_content_item.publishing_organisation["title"]
331+
expect(columns[1]).to have_text "Publisher"
332+
expect(columns[2]).to have_text host_content_item.document_type.humanize
333+
expect(columns[3]).to have_text "1"
334+
expect(columns[4]).to have_text "1.2m"
335+
expect(columns[5]).to have_text host_content_item.publishing_organisation["title"]
395336

396-
expect(columns[5]).to have_text "#{time_ago_in_words(host_content_item.last_edited_at)} ago by #{last_edited_by_editor.name}"
337+
expect(columns[6]).to have_text "#{time_ago_in_words(host_content_item.last_edited_at)} ago by #{last_edited_by_editor.name}"
397338

398-
expect(columns[5]).to have_css "a.govuk-link" do |link|
339+
expect(columns[6]).to have_css "a.govuk-link" do |link|
399340
expect(link.text).to eq(last_edited_by_editor.name)
400341
expect(link[:href]).to eq(user_path(last_edited_by_editor.uid))
401342
end
402343

403-
expect(columns[6]).to have_text "Preview #{host_content_item.title} (opens in new tab)"
344+
expect(columns[7]).to have_text "Preview #{host_content_item.title} (opens in new tab)"
404345

405-
expect(columns[6]).to have_css "a.govuk-link" do |link|
346+
expect(columns[7]).to have_css "a.govuk-link" do |link|
406347
expect(link.text).to eq("Preview #{host_content_item.title} (opens in new tab)")
407348
expect(link[:href]).to include("/preview")
408349
expect(link[:href]).to include("state=#{host_content_item.state}")
@@ -413,17 +354,9 @@ def self.it_returns_unknown_user
413354
let(:state) { "draft" }
414355

415356
it "includes the content item state in the preview link" do
416-
render_inline(
417-
described_class.new(
418-
caption:,
419-
host_content_items:,
420-
edition: in_progress_edition,
421-
),
422-
)
423-
424357
columns = page.find_all(".govuk-table__cell")
425358

426-
expect(columns[6]).to have_css "a.govuk-link" do |link|
359+
expect(columns[7]).to have_css "a.govuk-link" do |link|
427360
expect(link[:href]).to include("state=draft")
428361
end
429362
end

spec/features/embedded_content_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ def self.it_returns_embedded_content(&block)
1616
"base_path" => "/organisation/#{i}",
1717
},
1818
"state" => "published",
19+
"publishing_app" => "publisher",
1920
}
2021
end
2122
end

spec/requests/workflow_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,7 @@ def self.it_shows_the_correct_context
374374
"base_path" => "/organisation/#{i}",
375375
},
376376
"state" => "draft",
377+
"publishing_app" => "publisher",
377378
}
378379
end
379380
end

0 commit comments

Comments
 (0)