-
-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds an association as `Notable#concrete_notes` to avoid clashing with the current `PublicBody#notes` column. This uses a polymorphic association so any model can be `Notable`.
- Loading branch information
Showing
13 changed files
with
144 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module Notable | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
has_many :concrete_notes, | ||
class_name: 'Note', | ||
as: :notable, | ||
inverse_of: :notable, | ||
dependent: :destroy | ||
end | ||
|
||
def all_notes | ||
concrete_notes.with_translations | ||
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
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,31 @@ | ||
<div class="row"> | ||
<% if notes.size > 0 %> | ||
<table class="table table-condensed table-hover span12 censor-rule-list"> | ||
<tr> | ||
<th>ID</th> | ||
<th>Notable ID</th> | ||
<th>Notable type</th> | ||
<th>Notable tag</th> | ||
<th>Actions</th> | ||
</tr> | ||
|
||
<% notes.each do |note| %> | ||
<tr class="<%= cycle('odd', 'even') %>"> | ||
<td class="id"><%= h note.id %></td> | ||
<td class="notable_id"><%= h note.notable_id %></td> | ||
<td class="notable_type"><%= h note.notable_type %></td> | ||
<td class="notable_tag"><%= h note.notable_tag %></td> | ||
<td><%= link_to "Edit", edit_admin_note_path(note) %></td> | ||
</tr> | ||
<% end %> | ||
</table> | ||
<% else %> | ||
<p class="span12">None yet.</p> | ||
<% end %> | ||
</div> | ||
|
||
<div class="row"> | ||
<p class="span12"> | ||
<%= link_to "New note", new_admin_note_path(notable_type: notable.class, notable_id: notable), class: "btn btn-info" %> | ||
</p> | ||
</div> |
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
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,11 @@ | ||
RSpec.shared_examples 'concerns/notable' do |record| | ||
describe '#all_notes' do | ||
subject { record.all_notes } | ||
|
||
let!(:note) { FactoryBot.create(:note, notable: record) } | ||
let!(:other_note) { FactoryBot.create(:note) } | ||
|
||
it { is_expected.to include note } | ||
it { is_expected.to_not include other_note } | ||
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