Skip to content
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

Bump friendly #5321

Merged
merged 4 commits into from
Feb 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ gem "dalli", "~> 2.7"
gem "deprecated_columns", "~> 0.1.1"
gem "equivalent-xml", "~> 0.6.0", require: false
gem "faraday"
gem "friendly_id", "~> 5.2.4"
gem "friendly_id", "~> 5.3.0"
gem "fuzzy_match", "~> 2.1"
gem "gds-sso", "~> 14.2"
gem "globalize", "~> 5"
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ GEM
faraday (0.17.3)
multipart-post (>= 1.2, < 3)
ffi (1.12.2)
friendly_id (5.2.4)
friendly_id (5.3.0)
activerecord (>= 4.0.0)
fugit (1.3.3)
et-orbi (~> 1.1, >= 1.1.8)
Expand Down Expand Up @@ -582,7 +582,7 @@ DEPENDENCIES
equivalent-xml (~> 0.6.0)
factory_bot
faraday
friendly_id (~> 5.2.4)
friendly_id (~> 5.3.0)
fuzzy_match (~> 2.1)
gds-api-adapters
gds-sso (~> 14.2)
Expand Down
3 changes: 3 additions & 0 deletions app/models/attachment.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Abstract base class for Attachments.
class Attachment < ApplicationRecord
extend FriendlyId
friendly_id :title, use: :scoped, scope: :attachable

belongs_to :attachable, polymorphic: true
has_one :attachment_source

Expand Down
6 changes: 6 additions & 0 deletions app/models/external_attachment.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
class ExternalAttachment < Attachment
extend FriendlyId
include HasContentId
friendly_id { |config| config.routes = false }

validates :external_url, presence: true, uri: true, length: { maximum: 255 }

Expand All @@ -19,6 +21,10 @@ def csv?
false
end

def should_generate_new_friendly_id?
false
end

# Is in OpenDocument format? (see https://en.wikipedia.org/wiki/OpenDocument)
def opendocument?
false
Expand Down
6 changes: 6 additions & 0 deletions app/models/file_attachment.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
class FileAttachment < Attachment
extend FriendlyId
include HasContentId
friendly_id { |config| config.routes = false }

delegate :url,
:content_type,
Expand Down Expand Up @@ -30,6 +32,10 @@ def readable_type
"file"
end

def should_generate_new_friendly_id?
false
end

private

def filename_is_unique
Expand Down
1 change: 0 additions & 1 deletion app/models/html_attachment.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
class HtmlAttachment < Attachment
extend FriendlyId
friendly_id :title, use: :scoped, scope: :attachable

include HasContentId

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Attachment
.where.not(type: "HtmlAttachment")
.where.not(slug: nil)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor - this can be where.not(type: "HtmlAttachment", slug: nil)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, I normally like to put my where clauses on separate lines to be super explicit as I think it reads better but thats just personal preference!

.update_all(slug: nil)