-
-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🥔✨ Journal
: Sprout Keywords#show
#1649
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d214a4c
🥔✨ `Journal`: Sprout `Keywords#show`
zspencer 07e1562
Show Entries that match a Keyword or it's Aliases
zspencer 39f59ab
Use the canonical-keyword when building urls
zspencer 4db5e02
`Journal`: Extract `Entry.matching_keywords([...])` scope
zspencer 0d5ed0d
Spiff up the Presentation a touch
zspencer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,12 @@ | ||
<h1><%= keyword.canonical_keyword %></h1> | ||
<ul> | ||
<%= keyword&.aliases&.each do |aliass| %> | ||
<li><%= aliass %></li> | ||
<% end %> | ||
</ul> | ||
|
||
<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 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sssssssssss (thanks, Ruby)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was a/nnoyed/mused at the consequence of choosing
aliases
as a collection; and may wind up finding a different name to prevent the silliness.