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. 146
      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,100 +65,115 @@ 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 "w/o a project" do
let(:project) { nil }
let(:call_action) { get('index') }
describe 'html' do
describe "w/o a project" do
let(:project) { nil }
let(:call_action) { get('index') }
it 'should render the index template' do
call_action
it 'should render the index template' do
call_action
response.should render_template('work_packages/index', :formats => ["html"],
:layout => :base)
response.should render_template('work_packages/index', :formats => ["html"],
:layout => :base)
end
end
end
describe "w/ a project" do
let(:call_action) { get('index', :project_id => project.id) }
describe "w/ a project" do
let(:call_action) { get('index', :project_id => project.id) }
it 'should render the index template' do
call_action
it 'should render the index template' do
call_action
response.should render_template('work_packages/index', :formats => ["html"],
:layout => :base)
response.should render_template('work_packages/index', :formats => ["html"],
:layout => :base)
end
end
end
end
describe 'index.csv' do
before do
User.current.should_receive(:allowed_to?)
.with({ :controller => "work_packages",
:action => "index" },
project,
:global => true)
.and_return(true)
describe 'csv' do
before do
mock_csv = double('csv export')
mock_csv = double('csv export')
WorkPackage::Exporter.should_receive(:csv).with(work_packages, project)
.and_return(mock_csv)
WorkPackage::Exporter.should_receive(:csv).and_return(mock_csv)
controller.should_receive(:send_data).with(mock_csv,
:type => 'text/csv; header=present',
:filename => 'export.csv').and_call_original
end
controller.should_receive(:send_data).with(mock_csv,
:type => 'text/csv; header=present',
:filename => 'export.csv').and_call_original
end
describe "w/o a project" do
let(:project) { nil }
let(:call_action) { get('index', :format => 'csv') }
it 'should fulfill the defined should_receives' do
call_action
end
end
describe "w/o a project" do
let(:project) { nil }
let(:call_action) { get('index', :format => 'csv') }
describe "w/ a project" do
let(:call_action) { get('index', :project_id => project.id, :format => 'csv') }
it 'should fulfill the defined should_receives' do
call_action
it 'should fulfill the defined should_receives' do
call_action
end
end
end
describe "w/ a project" do
let(:call_action) { get('index', :project_id => project.id, :format => 'csv') }
describe 'pdf' do
before do
mock_pdf = double('pdf export')
WorkPackage::Exporter.should_receive(:pdf).and_return(mock_pdf)
it 'should fulfill the defined should_receives' do
call_action
controller.should_receive(:send_data).with(mock_pdf,
:type => 'application/pdf',
:filename => 'export.pdf').and_call_original
end
end
end
describe 'index.pdf' do
before do
User.current.should_receive(:allowed_to?)
.with({ :controller => "work_packages",
:action => "index" },
project,
:global => true)
.and_return(true)
describe "w/o a project" do
let(:project) { nil }
let(:call_action) { get('index', :format => 'pdf') }
mock_pdf = double('pdf export')
it 'should fulfill the defined should_receives' do
call_action
end
end
WorkPackage::Exporter.should_receive(:pdf).and_return(mock_pdf)
describe "w/ a project" do
let(:call_action) { get('index', :project_id => project.id, :format => 'pdf') }
controller.should_receive(:send_data).with(mock_pdf,
:type => 'application/pdf',
:filename => 'export.pdf').and_call_original
it 'should fulfill the defined should_receives' do
call_action
end
end
end
describe "w/o a project" do
let(:project) { nil }
let(:call_action) { get('index', :format => 'pdf') }
describe 'atom' do
before do
controller.should_receive(:render_feed).with(work_packages, anything()).and_call_original
end
it 'should fulfill the defined should_receives' do
call_action
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
end
describe "w/ a project" do
let(:call_action) { get('index', :project_id => project.id, :format => 'pdf') }
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
it 'should fulfill the defined should_receives' do
call_action
end
end
end

Loading…
Cancel
Save