-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 🥔✨ `Journal`: Sprout `Keywords#show` - https://github.com/zinc-collective/convene/issues/1566 - https://github.com/zinc-collective/convene/issues/1662 * Show Entries that match a Keyword or it's Aliases * Use the canonical-keyword when building urls * `Journal`: Extract `Entry.matching_keywords([...])` scope * Spiff up the Presentation a touch
- Loading branch information
Showing
8 changed files
with
68 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# frozen_string_literal: true | ||
|
||
class Journal | ||
class KeywordPolicy < ApplicationPolicy | ||
alias_method :keyword, :object | ||
|
||
def show? | ||
true | ||
end | ||
|
||
class Scope < ApplicationScope | ||
def resolve | ||
scope | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<h1><%= keyword.canonical_keyword %></h1> | ||
<%- if keyword.aliases.present? %> | ||
<p class="italic">Also known as <%= to_sentence(keyword.aliases) %></p> | ||
<%- end %> | ||
|
||
<h2>Entries about <span class="italic"><%= keyword.canonical_keyword %></span></h2> | ||
<ul> | ||
<%- policy_scope(keyword.entries).each do |entry|%> | ||
<li><%= link_to(entry.headline, entry.location) %></li> | ||
<%- end %> | ||
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class Journal | ||
class KeywordsController < FurnitureController | ||
expose(:keyword, scope: -> { policy_scope(journal.keywords) }, model: Keyword, | ||
find: ->(id, scope) { scope.find_by(canonical_keyword: id) }) | ||
|
||
expose(:journal, -> { Journal.find(params[:journal_id]) }) | ||
def show | ||
authorize(keyword) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
spec/furniture/journal/keywords_controller_request_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe Journal::KeywordsController, type: :request do | ||
describe "#show" do | ||
subject(:perform_request) do | ||
get polymorphic_path(keyword.location) | ||
response | ||
end | ||
|
||
let(:keyword) { create(:journal_keyword) } | ||
|
||
it { is_expected.to be_ok } | ||
end | ||
end |