Fixed: ActiveRecord::SerializationTypeMismatch
This commit is contained in:
parent
dca09050d0
commit
a1a70b562b
|
@ -24,7 +24,6 @@ class BuildList::Package < ActiveRecord::Base
|
|||
scope :like_name, ->(name) { where("#{table_name}.name ILIKE ?", "%#{name}%") if name.present? }
|
||||
|
||||
before_create :set_epoch
|
||||
before_create :normalize_dependent_packages
|
||||
|
||||
def assignee
|
||||
project.maintainer
|
||||
|
@ -47,12 +46,14 @@ class BuildList::Package < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def normalize_dependent_packages
|
||||
self.dependent_packages = dependent_packages.to_s.split(/\s/).select(&:present?)
|
||||
# Public: Set dependent_packages.
|
||||
def dependent_packages=(v)
|
||||
v = v.to_s.split(/\s/).select(&:present?) if v.is_a?(String)
|
||||
write_attribute :dependent_packages, v
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def set_epoch
|
||||
self.epoch = nil if epoch.blank? || epoch == 0
|
||||
end
|
||||
|
|
|
@ -4,17 +4,18 @@ describe BuildList::Package do
|
|||
before { stub_symlink_methods }
|
||||
|
||||
it 'is valid' do
|
||||
FactoryGirl.create(:build_list_package).should be_persisted
|
||||
expect(FactoryGirl.create(:build_list_package)).to be_persisted
|
||||
end
|
||||
|
||||
context '#set_epoch' do
|
||||
|
||||
describe '#set_epoch' do
|
||||
let(:package) { FactoryGirl.build(:build_list_package) }
|
||||
|
||||
['', '(none)'].each do |epoch|
|
||||
it "ensures that epoch is set to nil when epoch is '#{epoch}'" do
|
||||
package.epoch = epoch
|
||||
package.save
|
||||
package.epoch.should be_nil
|
||||
expect(package.epoch).to be_nil
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -22,9 +23,16 @@ describe BuildList::Package do
|
|||
it "ensures that valid epoch has been setted" do
|
||||
package.epoch = '55'
|
||||
package.save
|
||||
package.epoch.should == 55
|
||||
expect(package.epoch).to eq 55
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe '#dependent_packages=' do
|
||||
it 'sets a packages' do
|
||||
package = FactoryGirl.build(:build_list_package, dependent_packages: 'x y z')
|
||||
expect(package).to be_valid
|
||||
expect(package.dependent_packages).to eq %w(x y z)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue