Merge pull request #11 from finnlabs/feature/rspec-299

RSpec 2.99 Upgrade
pull/6827/head
ulferts 10 years ago
commit 17365a8932
  1. 32
      spec/lib/spreadsheet_builder_spec.rb
  2. 12
      spec/patches/cost_reports_controller_patch_spec.rb
  3. 28
      spec/patches/work_packages_controller_patch_spec.rb

@ -8,78 +8,78 @@ describe "SpreadsheetBuilder" do
it "should add a single title in the first row" do
@spreadsheet.add_title("A fancy title")
@sheet.last_row_index.should == 0
expect(@sheet.last_row_index).to eq(0)
end
it "should add the title complety in the first cell" do
title = "A fancy title"
@spreadsheet.add_title(title)
@sheet.last_row[0].should == title
@sheet.last_row[1].should == nil
expect(@sheet.last_row[0]).to eq(title)
expect(@sheet.last_row[1]).to eq(nil)
end
it "should overwrite titles in consecutive calls" do
title = "A fancy title"
@spreadsheet.add_title(title)
@spreadsheet.add_title(title)
@sheet.last_row_index.should == 0
expect(@sheet.last_row_index).to eq(0)
end
it "should do some formatting on the title" do
@spreadsheet.add_title("A fancy title")
@sheet.last_row.format(0).should_not == @sheet.last_row.format(1)
expect(@sheet.last_row.format(0)).not_to eq(@sheet.last_row.format(1))
end
it "should add empty rows starting in the second line" do
@spreadsheet.add_empty_row
@sheet.last_row_index.should == 1
expect(@sheet.last_row_index).to eq(1)
end
it "should add empty rows at the next sequential row" do
@spreadsheet.add_empty_row
first = @sheet.last_row_index
@spreadsheet.add_empty_row
@sheet.last_row_index.should == (first + 1)
expect(@sheet.last_row_index).to eq(first + 1)
end
it "should add headers in the second line per default" do
@spreadsheet.add_headers((1..3).to_a)
@sheet.last_row_index.should == 1
expect(@sheet.last_row_index).to eq(1)
end
it "should allow adding headers in the first line" do
@spreadsheet.add_headers((1..3).to_a, 0)
@sheet.last_row_index.should == 0
expect(@sheet.last_row_index).to eq(0)
end
it "should add headers with some formatting" do
@spreadsheet.add_headers([1], 0)
@sheet.last_row.format(0).should_not == @sheet.last_row.format(2)
expect(@sheet.last_row.format(0)).not_to eq(@sheet.last_row.format(2))
end
it "should start adding rows in the first line" do
@spreadsheet.add_row((1..3).to_a)
@sheet.last_row_index.should == 1
expect(@sheet.last_row_index).to eq(1)
end
it "should add rows sequentially" do
@spreadsheet.add_row((1..3).to_a)
first = @sheet.last_row_index
@spreadsheet.add_row((1..3).to_a)
@sheet.last_row_index.should == (first + 1)
expect(@sheet.last_row_index).to eq(first + 1)
end
it "should apply no formatting on rows" do
@spreadsheet.add_row([1])
@sheet.last_row.format(0).should == @sheet.last_row.format(1)
expect(@sheet.last_row.format(0)).to eq(@sheet.last_row.format(1))
end
it "should always use unix newlines" do
@spreadsheet.add_row(["Some text including a windows newline (\r\n)", "And an old-style mac os newline (\r)"])
2.times do |i|
@spreadsheet.send("raw_sheet").last_row[i].should_not include("\r")
@spreadsheet.send("raw_sheet").last_row[i].should_not include("\r\n")
@spreadsheet.send("raw_sheet").last_row[i].should include("\n")
expect(@spreadsheet.send("raw_sheet").last_row[i]).not_to include("\r")
expect(@spreadsheet.send("raw_sheet").last_row[i]).not_to include("\r\n")
expect(@spreadsheet.send("raw_sheet").last_row[i]).to include("\n")
end
end
end

@ -1,22 +1,22 @@
require 'spec_helper'
describe 'CostReportsController', "rendering to xls" do
pending 'XlsExport: CostReports support not yet migrated to Rails 3'
skip 'XlsExport: CostReports support not yet migrated to Rails 3'
it "should respond with the xls if requested in the index" do
pending
skip
render :action => :index
response.should be_redirect
expect(response).to be_redirect
end
it "should not respond with the xls if requested in a detail view" do
pending
skip
render :action => :show
response.should be_redirect
expect(response).to be_redirect
end
it "should generate xls from issues" do
pending
skip
end
end

@ -6,7 +6,7 @@ describe WorkPackagesController, "rendering to xls", :type => :controller do
:description => '!DESCRIPTION!') }
before do
User.stub(:current).and_return current_user
allow(User).to receive(:current).and_return current_user
end
describe "should respond with the xls if requested in the index" do
@ -15,23 +15,23 @@ describe WorkPackagesController, "rendering to xls", :type => :controller do
end
it 'should respond with 200 OK' do
response.response_code.should == 200
expect(response.response_code).to eq(200)
end
it 'should have a length > 100 bytes' do
response.body.length.should > 100
expect(response.body.length).to be > 100
end
it 'should not contain a description' do
response.body.should_not include('!DESCRIPTION!')
expect(response.body).not_to include('!DESCRIPTION!')
end
it 'should contain a subject' do
response.body.should include('!SUBJECT!')
expect(response.body).to include('!SUBJECT!')
end
context 'the mime type' do
it { response.header['Content-Type'].should == 'application/vnd.ms-excel' }
it { expect(response.header['Content-Type']).to eq('application/vnd.ms-excel') }
end
end
@ -56,15 +56,15 @@ describe WorkPackagesController, "rendering to xls", :type => :controller do
end
before do
OpenProject::XlsExport::Formatters::TimeFormatter.stub(:apply?) do |column|
allow(OpenProject::XlsExport::Formatters::TimeFormatter).to receive(:apply?) do |column|
column.caption =~ /time/i
end
OpenProject::XlsExport::Formatters::CostFormatter.stub(:apply?) do |column|
allow(OpenProject::XlsExport::Formatters::CostFormatter).to receive(:apply?) do |column|
column.caption =~ /cost/i
end
Setting.stub(:plugin_openproject_costs).and_return({ 'costs_currency' => 'EUR','costs_currency_format' => '%n %u' })
allow(Setting).to receive(:plugin_openproject_costs).and_return({ 'costs_currency' => 'EUR','costs_currency_format' => '%n %u' })
get 'index',
:format => 'xls',
@ -113,23 +113,23 @@ describe WorkPackagesController, "rendering to xls", :type => :controller do
end
it 'should respond with 200 OK' do
response.response_code.should == 200
expect(response.response_code).to eq(200)
end
it 'should have a length > 100 bytes' do
response.body.length.should > 100
expect(response.body.length).to be > 100
end
it 'should contain a description' do
response.body.should include('!DESCRIPTION!')
expect(response.body).to include('!DESCRIPTION!')
end
it 'should contain a subject' do
response.body.should include('!SUBJECT!')
expect(response.body).to include('!SUBJECT!')
end
context 'the mime type' do
it { response.header['Content-Type'].should == 'application/vnd.ms-excel' }
it { expect(response.header['Content-Type']).to eq('application/vnd.ms-excel') }
end
end

Loading…
Cancel
Save