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