Skip to content

Commit

Permalink
Journal: Don't explode on unpublished posts (#1027)
Browse files Browse the repository at this point in the history
See: #1026
See: https://github.com/zinc-collective/convene/issues/898

Welp, that's what I get for not testing that case!
  • Loading branch information
zspencer authored Jan 3, 2023
1 parent 8ed8cb4 commit 78c6dee
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 3 deletions.
5 changes: 5 additions & 0 deletions app/furniture/journal/breadcrumbs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
link entry.headline, entry.location
end

crumb :journal_entries do |journal|
parent :room, journal.room
link "Journal", journal.location
end

crumb :new_journal_entry do |entry|
parent :room, entry.room
link "Add a Journal Entry", journal.entries.new.location
Expand Down
2 changes: 1 addition & 1 deletion app/furniture/journal/entries/_entry.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<%- if policy(entry).update? %>
<%= link_to "Edit", entry.location(:edit) %>
<%- if !entry.published? %>
<%= link_to "Publish Now", entry.location() + [{ entry: { published_at: Time.now } }, data: { turbo_method: :put }] %>
<%= link_to "Publish Now", (entry.location() + [{ entry: { published_at: Time.now } }]), data: { turbo_method: :put } %>
<%- end %>
<%- end %>

Expand Down
3 changes: 3 additions & 0 deletions app/furniture/journal/entries/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<%- breadcrumb :journal_entries, journal %>

<%= render journal %>
3 changes: 3 additions & 0 deletions app/furniture/journal/entries_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ def destroy
authorize(@entry)
end

def index
end

helper_method def page_title
"#{entry.headline} - #{space.name}"
end
Expand Down
18 changes: 16 additions & 2 deletions spec/furniture/journal/entries_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,21 @@
let(:room) { journal.room }
let(:member) { create(:person, spaces: [space]) }

describe "POST /entries" do
describe "#index" do
it "shows all the journal entries" do
sign_in(space, member)
unpublished_entry = create(:journal_entry, journal: journal)
published_entry = create(:journal_entry, journal: journal, published_at: 1.week.ago)

get polymorphic_path(journal.location(child: :entries))

expect(response).to be_ok
expect(response.body).to include(published_entry.headline)
expect(response.body).to include(unpublished_entry.headline)
end
end

describe "#create" do
it "Creates an Entry in the Journal" do
sign_in(space, member)

Expand All @@ -22,7 +36,7 @@
end
end

describe "PUT /journals/:journal_id/entries/:entry_id" do
describe "#update" do
it "allows members to update Journal Entries" do
sign_in(space, member)
entry = create(:journal_entry, journal: journal)
Expand Down

0 comments on commit 78c6dee

Please sign in to comment.