Skip to content

Commit

Permalink
[webui] Don't render in the description in Notification::RssFeedItem
Browse files Browse the repository at this point in the history
Do it in the notification rss builder instead.
  • Loading branch information
hennevogel committed Jun 29, 2017
1 parent a1e23a6 commit 03622a0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 37 deletions.
1 change: 1 addition & 0 deletions src/api/app/controllers/webui/feeds_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def notifications
@configuration = ::Configuration.first
@user = token.user
@notifications = token.user.combined_rss_feed_items
@host = ::Configuration.obs_url
else
flash[:error] = "Unknown Token for RSS feed"
redirect_back(fallback_location: root_path)
Expand Down
13 changes: 0 additions & 13 deletions src/api/app/models/notification/rss_feed_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,6 @@ def self.cleanup
end
end
end

def title
event.subject
end

def description
ApplicationController.renderer.new.render(
template: "event_mailer/#{event.template_name}",
layout: false,
format: :txt,
assigns: { host: ::Configuration.obs_url, configuration: ::Configuration.first },
locals: { event: event})
end
end

# == Schema Information
Expand Down
13 changes: 9 additions & 4 deletions src/api/app/views/webui/feeds/notifications.rss.builder
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
xml.rss version: '2.0' do
xml.channel do
xml.title "#{@user.realname} (#{@user.login}) notifications"
xml.description "Event's notifications from #{@configuration['title']}"
xml.description "Event notifications from #{@configuration['title']}"
xml.link url_for only_path: false, controller: 'main', action: 'index'
xml.language "en"
xml.pubDate Time.now
xml.generator @configuration['title']

@notifications.each do |notification|
xml.item do
xml.title notification.title
xml.description notification.description
xml.title notification.event.subject
# We render the event_mailer view to 'description'
xml.description render(
template: "event_mailer/#{notification.event.template_name}",
layout: false,
formats: :text,
locals: { event: notification.event.expanded_payload })
xml.category "#{notification.event_type}/#{notification.subscription_receiver_role}"
xml.pubDate notification.created_at
xml.author @configuration['title'].to_s
xml.author @configuration['title']
end
end
end
Expand Down
20 changes: 0 additions & 20 deletions src/api/spec/models/notification/rss_feed_item_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,24 +82,4 @@
it { expect { Notification::RssFeedItem.cleanup }.to change { unconfirmed_user.rss_feed_items.count }.by(-greater_than_max_items_per_user) }
end
end

describe '#title' do
subject { create(:rss_notification, event_type: 'Event::DeletePackage', event_payload: payload) }

it { expect(subject.title).to eq(delete_package_event.subject) }
end

describe '#description' do
let(:rendered_view) do
ApplicationController.renderer.new.render(
template: "event_mailer/#{delete_package_event.template_name}",
layout: false,
format: :txt,
assigns: { host: ::Configuration.obs_url, configuration: ::Configuration.first },
locals: { event: delete_package_event })
end
subject { create(:rss_notification, event_type: 'Event::DeletePackage', event_payload: payload) }

it { expect(subject.description).to eq(rendered_view) }
end
end

0 comments on commit 03622a0

Please sign in to comment.