enables atom feed for work_packages#index

pull/388/head
Jens Ulferts 11 years ago
parent 310f780edd
commit 7ac5461542
  1. 7
      app/controllers/work_packages_controller.rb
  2. 54
      spec/controllers/work_packages_controller_spec.rb

@ -206,7 +206,8 @@ class WorkPackagesController < ApplicationController
:order => sort_clause)
work_packages = results.work_packages.page(page_param)
.per_page(per_page_param).all
.per_page(per_page_param)
.all
respond_to do |format|
format.html do
@ -233,6 +234,10 @@ class WorkPackagesController < ApplicationController
:type => 'application/pdf',
:filename => 'export.pdf')
end
format.atom do
render_feed(work_packages,
:title => "#{@project || Setting.app_title}: #{l(:label_work_package_plural)}")
end
end
end

@ -54,7 +54,10 @@ describe WorkPackagesController do
end
end
describe 'index.html' do
describe 'index' do
let(:query) { FactoryGirl.build_stubbed(:query) }
let(:work_packages) { double("work packages").as_null_object }
before do
User.current.should_receive(:allowed_to?)
.with({ :controller => "work_packages",
@ -62,8 +65,12 @@ describe WorkPackagesController do
project,
:global => true)
.and_return(true)
controller.stub(:retrieve_query).and_return(query)
query.stub_chain(:results, :work_packages, :page, :per_page, :all).and_return(work_packages)
end
describe 'html' do
describe "w/o a project" do
let(:project) { nil }
let(:call_action) { get('index') }
@ -88,18 +95,12 @@ describe WorkPackagesController do
end
end
describe 'index.csv' do
describe 'csv' do
before do
User.current.should_receive(:allowed_to?)
.with({ :controller => "work_packages",
:action => "index" },
project,
:global => true)
.and_return(true)
mock_csv = double('csv export')
WorkPackage::Exporter.should_receive(:csv).and_return(mock_csv)
WorkPackage::Exporter.should_receive(:csv).with(work_packages, project)
.and_return(mock_csv)
controller.should_receive(:send_data).with(mock_csv,
:type => 'text/csv; header=present',
@ -124,15 +125,8 @@ describe WorkPackagesController do
end
end
describe 'index.pdf' do
describe 'pdf' do
before do
User.current.should_receive(:allowed_to?)
.with({ :controller => "work_packages",
:action => "index" },
project,
:global => true)
.and_return(true)
mock_pdf = double('pdf export')
WorkPackage::Exporter.should_receive(:pdf).and_return(mock_pdf)
@ -158,6 +152,30 @@ describe WorkPackagesController do
call_action
end
end
end
describe 'atom' do
before do
controller.should_receive(:render_feed).with(work_packages, anything()).and_call_original
end
describe "w/o a project" do
let(:project) { nil }
let(:call_action) { get('index', :format => 'atom') }
it 'should fulfill the defined should_receives' do
call_action
end
end
describe "w/ a project" do
let(:call_action) { get('index', :project_id => project.id, :format => 'atom') }
it 'should fulfill the defined should_receives' do
call_action
end
end
end
end

Loading…
Cancel
Save