Skip to content

Commit

Permalink
chore: add rails4 support
Browse files Browse the repository at this point in the history
  • Loading branch information
vadshalamov committed Mar 28, 2017
1 parent 01bfe56 commit 5f930e3
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 11 deletions.
8 changes: 6 additions & 2 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
appraise 'activesupport3.2' do
gem 'activesupport', '~> 3.2.0'
appraise 'rails3.2' do
gem 'rails', '~> 3.2.0'
end

appraise 'rails4.0' do
gem 'rails', '~> 4.0.0'
end
2 changes: 1 addition & 1 deletion lib/treasury/fields/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ def self.accessing_field

def data_changed(changed_objects)
@changed_objects = changed_objects
run_callbacks(:data_changed, :after)
run_callbacks :data_changed
end

# Public: Рабочее соединение с БД для данной очереди.
Expand Down
6 changes: 2 additions & 4 deletions spec/lib/treasury/fields/base_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ module FieldCallback
set_callback :data_changed, :after, :data_changed_callback
end

module InstanceMethods
def data_changed_callback; end
end
def data_changed_callback; end
end

class TreasuryFieldsBase < Treasury::Fields::Base
Expand All @@ -23,7 +21,7 @@ class TreasuryFieldsBase < Treasury::Fields::Base
let(:chaged_objects) { [1, 2, 3] }

it 'run callbacks' do
expect(subject).to receive(:run_callbacks).with(:data_changed, :after)
expect(subject).to receive(:run_callbacks).with(:data_changed)
subject.send(:data_changed, chaged_objects)
end

Expand Down
2 changes: 1 addition & 1 deletion spec/lib/treasury/processors/base_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def form_value(value)
end

it 'должен вызывать метод API pgq_next_batch и транслировать родительское исключение, если не обработано' do
allow(ActiveRecord::Base).to receive(:pgq_next_batch).and_raise(ActiveRecord::StatementInvalid)
allow(ActiveRecord::Base).to receive(:pgq_next_batch).and_raise(ActiveRecord::StatementInvalid.new(''))
expect { subject.send(:get_batch) }.to raise_error(ActiveRecord::StatementInvalid)
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/models/field_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# coding: utf-8

describe Treasury::Models::Field do
describe Treasury::Models::Field, type: :model do
context 'when check db structure' do
it { is_expected.to have_db_column(:title).of_type(:string).with_options(limit: 128, null: false) }
it { is_expected.to have_db_column(:group).of_type(:string).with_options(limit: 128, null: false) }
Expand Down
2 changes: 1 addition & 1 deletion spec/models/queue_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# coding: utf-8

describe Treasury::Models::Queue do
describe Treasury::Models::Queue, type: :model do
context 'when check db structure' do
it { is_expected.to have_db_column(:name).of_type(:string).with_options(limit: 128, null: false) }
it { is_expected.to have_db_column(:table_name).of_type(:string).with_options(limit: 256, null: true) }
Expand Down
12 changes: 11 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
require 'pry-byebug'

SimpleCov.start do
minimum_coverage 73.5
minimum_coverage 73
end

Combustion.initialize! :action_mailer, :active_record
Expand All @@ -32,3 +32,13 @@
config.before(:each) { Treasury.configuration.redis.flushall }
config.after(:each) { Treasury.configuration.redis.flushall }
end

if Rails::VERSION::MAJOR >= 4
Shoulda::Matchers.configure do |config|
config.integrate do |with|
with.test_framework :rspec

with.library :rails
end
end
end

0 comments on commit 5f930e3

Please sign in to comment.