Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated: rspec-rails from ~>4.0.0.beta2 to ~>6.0.0 #3531

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ group :test do
gem 'falcon'
gem 'falcon-capybara'

# TODO: Use beta source for Rails 6 support
gem 'rspec-rails', '~> 4.0.0.beta3'
gem 'rspec-rails', '~> 6.0.0'
end

# Load local gems according to Refinery developer preference.
Expand Down
4 changes: 2 additions & 2 deletions core/app/views/refinery/admin/_error_messages.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<li><%= value %></li>
<% end %>
<% else %>
<% object.errors.each do |key, value| %>
<li><%= value %></li>
<% object.errors.each do |error| %>
<li><%= error.message %></li>
<% end %>
<% end %>
</ul>
Expand Down
9 changes: 5 additions & 4 deletions core/lib/generators/refinery/cms/cms_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ class CmsGenerator < Rails::Generators::Base
:desc => "Skip over installing or running migrations."

def generate
start_pretending?
saved_pretend = start_pretending?

manage_roadblocks! unless self.options[:update]

ensure_environments_are_sane!

stop_pretending?
stop_pretending? saved_pretend

append_gemfile!

Expand Down Expand Up @@ -333,15 +333,16 @@ def start_pretending?
new_options = self.options.dup
new_options[:pretend] = true
self.options = new_options
old_pretend
end
end

def stop_pretending?
def stop_pretending?(saved_pretend)
# Stop pretending
if destination_path == Refinery.root
say_status :'-- finished pretending --', nil, :yellow
new_options = self.options.dup
new_options[:pretend] = old_pretend
new_options[:pretend] = saved_pretend
self.options = new_options
end
end
Expand Down
6 changes: 3 additions & 3 deletions images/lib/refinery/images/validators/image_size_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ def validate(record)
image = record.image

if image.respond_to?(:length) && image.length > Images.max_image_size
record.errors[:image] << ::I18n.t('too_big',
:scope => 'activerecord.errors.models.refinery/image',
:size => Images.max_image_size)
record.errors.add :too_big, ::I18n.t('too_big',
scope: 'activerecord.errors.models.refinery/image',
size: Images.max_image_size)
end
end

Expand Down
4 changes: 2 additions & 2 deletions images/spec/models/refinery/image_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require 'uri'

module Refinery
describe Image, :type => :model do
describe Image, type: :model do

let(:image) { FactoryBot.build(:image) }
let(:created_image) { FactoryBot.create(:image) }
Expand Down Expand Up @@ -37,7 +37,7 @@ module Refinery
it "should contain an error message" do
@image.valid?
expect(@image.errors).not_to be_empty
expect(@image.errors[:image]).to eq(["Image should be smaller than #{Images.max_image_size} bytes in size"])
expect(@image.errors[:too_big]).to eq(["Image should be smaller than #{Images.max_image_size} bytes in size"])
end
end

Expand Down
8 changes: 3 additions & 5 deletions images/spec/support/shared_examples/image_deleter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,16 @@
end

let(:image_count) {[Refinery::Image.count, Refinery::Images.pages_per_admin_index].min}
let(:deleting_an_image) {
-> {
first("#records li").click_link(::I18n.t('delete', scope: 'refinery.admin.images'))
}
let(:deleting_an_image) {
first("#records li").click_link(::I18n.t('delete', scope: 'refinery.admin.images'))
}

it 'has a delete image link for each image' do
expect(page).to have_selector('#records.images li a.confirm-delete', count: image_count)
end

it "removes an image" do
expect(deleting_an_image).to change(Refinery::Image, :count).by(-1)
expect{ deleting_an_image }.to change(Refinery::Image, :count).by(-1)
end

it 'says the image has been removed' do
Expand Down
6 changes: 2 additions & 4 deletions images/spec/support/shared_examples/image_uploader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
end

let(:uploading_an_image) {
->{
open_upload_dialog
page.within_frame(dialog_frame_id) do
select_upload
Expand All @@ -15,20 +14,19 @@
fill_in 'image_image_alt', with: "Alt description for image"
click_button ::I18n.t('save', scope: 'refinery.admin.form_actions')
end
}
}

context 'when the image type is acceptable' do
let(:image_path) {Refinery.roots('refinery/images').join("spec/fixtures/image-with-dashes.jpg")}
it 'the image is uploaded', :js => true do
expect(uploading_an_image).to change(Refinery::Image, :count).by(1)
expect { uploading_an_image }.to change(Refinery::Image, :count).by(1)
end
end

context 'when the image type is not acceptable' do
let(:image_path) {Refinery.roots('refinery/images').join("spec/fixtures/cape-town-tide-table.pdf")}
it 'the image is rejected', :js => true do
expect(uploading_an_image).to_not change(Refinery::Image, :count)
expect { uploading_an_image }.to_not change(Refinery::Image, :count)
page.within_frame(dialog_frame_id) do
expect(page).to have_content(::I18n.t('incorrect_format',
:scope => 'activerecord.errors.models.refinery/image',
Expand Down
4 changes: 0 additions & 4 deletions images/spec/support/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,3 @@ def has_image?(src)
def ensure_on(path)
visit(path) unless current_path == path
end

RSpec.configure do |c|
c.alias_it_should_behave_like_to :it_has_behaviour, 'has behaviour:'
end
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ def validate(record)
file = record.file

if file.respond_to?(:length) && file.length > Resources.max_file_size
record.errors[:file] << ::I18n.t('too_big',
:scope => 'activerecord.errors.models.refinery/resource',
:size => Resources.max_file_size)
record.errors.add :too_big, ::I18n.t('too_big',
scope: 'activerecord.errors.models.refinery/resource',
size: Resources.max_file_size)
end
end

Expand Down
4 changes: 2 additions & 2 deletions resources/spec/models/refinery/resource_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,10 @@ module Refinery
it 'should contain an error message' do
@resource.valid?
expect(@resource.errors).not_to be_empty
expect(@resource.errors[:file]).to eq(Array(::I18n.t(
expect(@resource.errors[:too_big]).to eq([::I18n.t(
'too_big', scope: 'activerecord.errors.models.refinery/resource',
size: Resources.max_file_size
)))
)])
end
end

Expand Down
18 changes: 8 additions & 10 deletions resources/spec/system/refinery/admin/resources_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,30 @@ module Admin

context 'new/create' do
let(:uploading_a_file) do
lambda do
visit refinery.admin_resources_path
find('a', text: 'Upload new file').click
visit refinery.admin_resources_path
find('a', text: 'Upload new file').click

expect(page).to have_selector 'iframe#dialog_iframe'
expect(page).to have_selector 'iframe#dialog_iframe'

page.within_frame('dialog_iframe') do
attach_file 'resource_file', file_path
click_button ::I18n.t('save', scope: 'refinery.admin.form_actions')
end
page.within_frame('dialog_iframe') do
attach_file 'resource_file', file_path
click_button ::I18n.t('save', scope: 'refinery.admin.form_actions')
end
end

context 'when the file mime_type is acceptable' do
let(:file_path) { Refinery.roots('refinery/resources').join('spec/fixtures/cape-town-tide-table.pdf') }

it 'the file is uploaded', js: true do
expect(uploading_a_file).to change(Refinery::Resource, :count).by(1)
expect { uploading_a_file }.to change(Refinery::Resource, :count).by(1)
end
end

context 'when the file mime_type is not acceptable' do
let(:file_path) { Refinery.roots('refinery/resources').join('spec/fixtures/refinery_is_secure.html') }

it 'the file is rejected', js: true do
expect(uploading_a_file).to_not change(Refinery::Resource, :count)
expect { uploading_a_file }.to_not change(Refinery::Resource, :count)

page.within_frame('dialog_iframe') do
expect(page).to have_content(::I18n.t('incorrect_format', scope: 'activerecord.errors.models.refinery/resource'))
Expand Down
6 changes: 6 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@

# Store last errors so we can run rspec with --only-failures
config.example_status_persistence_file_path = ".rspec_failures"

# it_has_behaviour alias is used in several gems.
config.alias_it_should_behave_like_to :it_has_behaviour, 'has behaviour:'

# for use when chasing deprecations
# config.raise_errors_for_deprecations!
end

# Requires supporting files with custom matchers and macros, etc,
Expand Down
2 changes: 1 addition & 1 deletion testing/refinerycms-testing.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Gem::Specification.new do |s|
s.add_dependency 'factory_bot_rails', '~> 4.8'
s.add_dependency 'rails-controller-testing', '>= 0.1.1'
s.add_dependency 'refinerycms-core', version
s.add_dependency 'rspec-rails', '~> 4.0.0.beta2'
s.add_dependency 'rspec-rails', '~> 6.0.0'
s.add_dependency 'webdrivers', '~> 4.0'

s.required_ruby_version = Refinery::Version.required_ruby_version
Expand Down
Loading