diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-06-24 16:17:16 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-06-24 16:17:16 +0200 |
| commit | 75670df5b8a5700c48ac8cb41f8d1732b5738402 (patch) | |
| tree | 0611ab89cd9fa6aa5c1c7cc44df28de4388c608e /app/controllers | |
| parent | 61dc69cc5d8089ed9f96bc65dc64de6e075f70cf (diff) | |
Fix tagged content aggregator, assets path, and add regression tests
- Replace tagged_with calls in Page.aggregate, TagsController, RssController
with direct SQL joins (acts-as-taggable-on 3.5 broken on Rails 3.2)
- Fix Paperclip :path/:url to use plain :id format matching existing uploads
- Add proper regression tests for aggregator, tags, and rss controllers
- Fix assert_select assertions to target div.body div.article_partial
Diffstat (limited to 'app/controllers')
| -rw-r--r-- | app/controllers/rss_controller.rb | 11 | ||||
| -rw-r--r-- | app/controllers/tags_controller.rb | 18 |
2 files changed, 20 insertions, 9 deletions
diff --git a/app/controllers/rss_controller.rb b/app/controllers/rss_controller.rb index 70a642c..be9cd2c 100644 --- a/app/controllers/rss_controller.rb +++ b/app/controllers/rss_controller.rb | |||
| @@ -7,10 +7,15 @@ class RssController < ApplicationController | |||
| 7 | expires_in 31.minutes, :public => true | 7 | expires_in 31.minutes, :public => true |
| 8 | 8 | ||
| 9 | I18n.locale = :de | 9 | I18n.locale = :de |
| 10 | 10 | ||
| 11 | @items = Page.heads.tagged_with("update") | 11 | @items = Page.heads |
| 12 | .joins("JOIN taggings ON taggings.taggable_id = pages.id | ||
| 13 | AND taggings.taggable_type = 'Page' | ||
| 14 | AND taggings.context = 'tags'") | ||
| 15 | .joins("JOIN tags ON tags.id = taggings.tag_id") | ||
| 16 | .where("LOWER(tags.name) = ?", "update") | ||
| 12 | .order("published_at DESC").limit(20) | 17 | .order("published_at DESC").limit(20) |
| 13 | 18 | ||
| 14 | respond_to do |format| | 19 | respond_to do |format| |
| 15 | format.xml {} | 20 | format.xml {} |
| 16 | format.rdf {} | 21 | format.rdf {} |
diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index f09d560..e4ceec9 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb | |||
| @@ -12,17 +12,23 @@ class TagsController < ApplicationController | |||
| 12 | tag_name = params[:id] | 12 | tag_name = params[:id] |
| 13 | 13 | ||
| 14 | if tag_name.match(/^[a-zA-Z0-9_\w\s\-\.\']+$/) | 14 | if tag_name.match(/^[a-zA-Z0-9_\w\s\-\.\']+$/) |
| 15 | @tag = Tag.find_by_name(tag_name) | 15 | @tag = ActsAsTaggableOn::Tag.find_by_name(tag_name) |
| 16 | @tag = @tag ? @tag.name : tag_name | 16 | @tag = @tag ? @tag.name : tag_name |
| 17 | @page = Page.new | 17 | @page = Page.new |
| 18 | 18 | ||
| 19 | params[:page] = (params[:page].is_a?(Integer) ? params[:page] : 1) | 19 | params[:page] = (params[:page].is_a?(Integer) ? params[:page] : 1) |
| 20 | 20 | ||
| 21 | @pages = Page.heads.tagged_with(@tag).paginate( | 21 | @pages = Page.heads |
| 22 | :order => 'published_at DESC', | 22 | .joins("JOIN taggings ON taggings.taggable_id = pages.id |
| 23 | :page => params[:page], | 23 | AND taggings.taggable_type = 'Page' |
| 24 | :per_page => 23 | 24 | AND taggings.context = 'tags'") |
| 25 | ) | 25 | .joins("JOIN tags ON tags.id = taggings.tag_id") |
| 26 | .where("LOWER(tags.name) = ?", @tag.downcase) | ||
| 27 | .order('published_at DESC') | ||
| 28 | .paginate( | ||
| 29 | :page => params[:page], | ||
| 30 | :per_page => 23 | ||
| 31 | ) | ||
| 26 | 32 | ||
| 27 | respond_to do |format| | 33 | respond_to do |format| |
| 28 | format.html {} | 34 | format.html {} |
