diff options
author | Timothy Andrew <mail@timothyandrew.net> | 2016-07-25 06:07:46 +0300 |
---|---|---|
committer | Timothy Andrew <mail@timothyandrew.net> | 2016-07-25 06:52:47 +0300 |
commit | 42a00f740b04555d9150f900145b4dd685000aaf (patch) | |
tree | ad5cf0a34ae31c1050baee5b65643a8939ead837 /app/models | |
parent | 58178a4f0cfc388be0d2f97906bece56ac4c543c (diff) |
`WikiPage` should have a slug even when not persisted.
1. So we can build the markdown preview URL for it.
2. We can't skip the slug in this case, because the slug is used to
construct relative markdown URLs.
3. Add rspec feature tests to cover creating wiki pages with
spaces/hyphens in the name.
4. Add rspec feature tests for markdown preview URL rewriting, which was
only covered by unit tests up to this point.
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/wiki_page.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/app/models/wiki_page.rb b/app/models/wiki_page.rb index 3d5fd9d3ee9..c3de278f5b7 100644 --- a/app/models/wiki_page.rb +++ b/app/models/wiki_page.rb @@ -44,7 +44,11 @@ class WikiPage # The escaped URL path of this page. def slug - @attributes[:slug] + if @attributes[:slug].present? + @attributes[:slug] + else + wiki.wiki.preview_page(title, '', format).url_path + end end alias_method :to_param, :slug |