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

RSpec 2.99 Upgrade
pull/6827/head
ulferts 10 years ago
commit b8478be9a4
  1. 36
      spec/controllers/export_card_configurations_controller_spec.rb
  2. 12
      spec/export_card/document_generator_spec.rb
  3. 14
      spec/views/edit.html.erb_spec.rb
  4. 6
      spec/views/index.html.erb_spec.rb
  5. 12
      spec/views/new.html.erb_spec.rb

@ -27,9 +27,9 @@
require 'spec_helper'
require File.dirname(__FILE__) + '/../shared_examples'
describe ExportCardConfigurationsController do
describe ExportCardConfigurationsController, :type => :controller do
before do
@controller.stub(:require_admin) { true }
allow(@controller).to receive(:require_admin) { true }
@default_config = FactoryGirl.create(:default_export_card_configuration)
@custom_config = FactoryGirl.create(:export_card_configuration)
@ -86,8 +86,8 @@ describe ExportCardConfigurationsController do
@params[:export_card_configuration] = { per_page: 4 }
put 'update', @params
response.should redirect_to :action => 'index'
flash[:notice].should eql(I18n.t(:notice_successful_update))
expect(response).to redirect_to :action => 'index'
expect(flash[:notice]).to eql(I18n.t(:notice_successful_update))
end
it 'should not let you update a configuration with invalid per_page' do
@ -95,7 +95,7 @@ describe ExportCardConfigurationsController do
@params[:export_card_configuration] = { per_page: 0}
put 'update', @params
response.should render_template('edit')
expect(response).to render_template('edit')
end
it 'should not let you update a configuration with invalid page_size' do
@ -103,7 +103,7 @@ describe ExportCardConfigurationsController do
@params[:export_card_configuration] = { page_size: "invalid"}
put 'update', @params
response.should render_template('edit')
expect(response).to render_template('edit')
end
it 'should not let you update a configuration with invalid orientation' do
@ -111,7 +111,7 @@ describe ExportCardConfigurationsController do
@params[:export_card_configuration] = { orientation: "invalid"}
put 'update', @params
response.should render_template('edit')
expect(response).to render_template('edit')
end
it 'should not let you update a configuration with invalid rows yaml' do
@ -119,7 +119,7 @@ describe ExportCardConfigurationsController do
@params[:export_card_configuration] = { rows: "asdf ',#\""}
put 'update', @params
response.should render_template('edit')
expect(response).to render_template('edit')
end
end
@ -128,16 +128,16 @@ describe ExportCardConfigurationsController do
@params[:id] = @custom_config.id
delete 'destroy', @params
response.should redirect_to :action => 'index'
flash[:notice].should eql(I18n.t(:notice_successful_delete))
expect(response).to redirect_to :action => 'index'
expect(flash[:notice]).to eql(I18n.t(:notice_successful_delete))
end
it 'should not let you delete the default configuration' do
@params[:id] = @default_config.id
delete 'destroy', @params
response.should redirect_to :action => 'index'
flash[:notice].should eql(I18n.t(:error_can_not_delete_export_card_configuration))
expect(response).to redirect_to :action => 'index'
expect(flash[:notice]).to eql(I18n.t(:error_can_not_delete_export_card_configuration))
end
end
@ -146,8 +146,8 @@ describe ExportCardConfigurationsController do
@params[:id] = @inactive_config.id
post 'activate', @params
response.should redirect_to :action => 'index'
flash[:notice].should eql(I18n.t(:notice_export_card_configuration_activated))
expect(response).to redirect_to :action => 'index'
expect(flash[:notice]).to eql(I18n.t(:notice_export_card_configuration_activated))
end
end
@ -156,16 +156,16 @@ describe ExportCardConfigurationsController do
@params[:id] = @active_config.id
post 'deactivate', @params
response.should redirect_to :action => 'index'
flash[:notice].should eql(I18n.t(:notice_export_card_configuration_deactivated))
expect(response).to redirect_to :action => 'index'
expect(flash[:notice]).to eql(I18n.t(:notice_export_card_configuration_deactivated))
end
it 'should not let you de-activate the default configuration' do
@params[:id] = @default_config.id
post 'deactivate', @params
response.should redirect_to :action => 'index'
flash[:notice].should eql(I18n.t(:error_can_not_deactivate_export_card_configuration))
expect(response).to redirect_to :action => 'index'
expect(flash[:notice]).to eql(I18n.t(:error_can_not_deactivate_export_card_configuration))
end
end
end

@ -53,17 +53,17 @@ describe OpenProject::PdfExport::ExportCard::DocumentGenerator do
it 'shows work package subject' do
text_analysis = PDF::Inspector::Text.analyze(@generator.render)
text_analysis.strings.include?('Work package 1').should be_true
expect(text_analysis.strings.include?('Work package 1')).to be_truthy
end
it 'does not show non existent field label' do
text_analysis = PDF::Inspector::Text.analyze(@generator.render)
text_analysis.strings.include?('Non existent:').should be_false
expect(text_analysis.strings.include?('Non existent:')).to be_falsey
end
it 'should be 1 page' do
page_analysis = PDF::Inspector::Page.analyze(@generator.render)
page_analysis.pages.size.should == 1
expect(page_analysis.pages.size).to eq(1)
end
end
@ -75,13 +75,13 @@ describe OpenProject::PdfExport::ExportCard::DocumentGenerator do
it 'shows work package subject' do
text = PDF::Inspector::Text.analyze(@generator.render)
text.strings.include?('Work package 1').should be_true
text.strings.include?('Work package 2').should be_true
expect(text.strings.include?('Work package 1')).to be_truthy
expect(text.strings.include?('Work package 2')).to be_truthy
end
it 'should be 2 pages' do
page_analysis = PDF::Inspector::Page.analyze(@generator.render)
page_analysis.pages.size.should == 2
expect(page_analysis.pages.size).to eq(2)
end
end

@ -26,7 +26,7 @@
require 'spec_helper'
describe 'export_card_configurations/edit' do
describe 'export_card_configurations/edit', :type => :view do
let(:config) { FactoryGirl.build(:export_card_configuration) }
before do
@ -37,12 +37,12 @@ describe 'export_card_configurations/edit' do
it 'shows edit export card configuration inputs' do
render
rendered.should have_field("Name", with: config.name)
rendered.should have_field("Description", with: config.description)
rendered.should have_field("Per page", with: config.per_page.to_s)
rendered.should have_field("Page size", with: config.page_size)
rendered.should have_field("Orientation", with: config.orientation)
rendered.should have_field("Rows", with: config.rows)
expect(rendered).to have_field("Name", with: config.name)
expect(rendered).to have_field("Description", with: config.description)
expect(rendered).to have_field("Per page", with: config.per_page.to_s)
expect(rendered).to have_field("Page size", with: config.page_size)
expect(rendered).to have_field("Orientation", with: config.orientation)
expect(rendered).to have_field("Rows", with: config.rows)
end
end

@ -26,7 +26,7 @@
require 'spec_helper'
describe 'export_card_configurations/index' do
describe 'export_card_configurations/index', :type => :view do
let(:config1) { FactoryGirl.build(:export_card_configuration, name: "Config 1") }
let(:config2) { FactoryGirl.build(:export_card_configuration, name: "Config 2") }
@ -39,8 +39,8 @@ describe 'export_card_configurations/index' do
it 'shows export card configurations' do
render
rendered.should have_selector("a", text: config1.name)
rendered.should have_selector("a", text: config2.name)
expect(rendered).to have_selector("a", text: config1.name)
expect(rendered).to have_selector("a", text: config2.name)
end
end

@ -26,7 +26,7 @@
require 'spec_helper'
describe 'export_card_configurations/new' do
describe 'export_card_configurations/new', :type => :view do
let(:config) { FactoryGirl.build(:export_card_configuration) }
before do
@ -36,11 +36,11 @@ describe 'export_card_configurations/new' do
it 'shows new export card configuration empty inputs' do
render
rendered.should have_css("input#export_card_configuration_name")
rendered.should have_css("input#export_card_configuration_per_page")
rendered.should have_css("input#export_card_configuration_page_size")
rendered.should have_css("select#export_card_configuration_orientation")
rendered.should have_css("textarea#export_card_configuration_rows")
expect(rendered).to have_css("input#export_card_configuration_name")
expect(rendered).to have_css("input#export_card_configuration_per_page")
expect(rendered).to have_css("input#export_card_configuration_page_size")
expect(rendered).to have_css("select#export_card_configuration_orientation")
expect(rendered).to have_css("textarea#export_card_configuration_rows")
end
end

Loading…
Cancel
Save