#301: added epoch field into package
This commit is contained in:
parent
198cb75711
commit
fcef6c25f3
|
@ -5,8 +5,7 @@ class BuildList::Package < ActiveRecord::Base
|
|||
belongs_to :project
|
||||
belongs_to :platform
|
||||
|
||||
attr_accessor :epoch
|
||||
attr_accessible :fullname, :name, :release, :version, :sha1
|
||||
attr_accessible :fullname, :name, :release, :version, :sha1, :epoch
|
||||
|
||||
validates :build_list_id, :project_id, :platform_id, :fullname,
|
||||
:package_type, :name, :release, :version,
|
||||
|
@ -23,6 +22,8 @@ class BuildList::Package < ActiveRecord::Base
|
|||
scope :by_package_type, lambda {|type| where(:package_type => type) }
|
||||
scope :like_name, lambda {|name| where("#{table_name}.name ILIKE ?", "%#{name}%") if name.present?}
|
||||
|
||||
before_create :set_epoch
|
||||
|
||||
def assignee
|
||||
project.maintainer
|
||||
end
|
||||
|
@ -38,11 +39,15 @@ class BuildList::Package < ActiveRecord::Base
|
|||
|
||||
protected
|
||||
|
||||
def set_epoch
|
||||
self.epoch = nil if epoch.blank? || epoch == 0
|
||||
end
|
||||
|
||||
# String representation in the form "e:v-r"
|
||||
# @return [String]
|
||||
# @note The epoch is included always. As 0 if not present
|
||||
def to_vre_epoch_zero
|
||||
evr = epoch.present? ? "#{epoch.to_i}:#{version}" : "0:#{version}"
|
||||
evr = epoch.present? ? "#{epoch}:#{version}" : "0:#{version}"
|
||||
evr << "-#{release}" if release.present?
|
||||
evr
|
||||
end
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddEpochToBuildListPackage < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :build_list_packages, :epoch, :integer
|
||||
end
|
||||
end
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20130829161042) do
|
||||
ActiveRecord::Schema.define(:version => 20130912113545) do
|
||||
|
||||
create_table "activity_feeds", :force => true do |t|
|
||||
t.integer "user_id", :null => false
|
||||
|
@ -95,6 +95,7 @@ ActiveRecord::Schema.define(:version => 20130829161042) do
|
|||
t.datetime "updated_at", :null => false
|
||||
t.boolean "actual", :default => false
|
||||
t.string "sha1"
|
||||
t.integer "epoch"
|
||||
end
|
||||
|
||||
add_index "build_list_packages", ["actual", "platform_id"], :name => "index_build_list_packages_on_actual_and_platform_id"
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
# -*- encoding : utf-8 -*-
|
||||
require 'spec_helper'
|
||||
|
||||
describe BuildList::Package do
|
||||
before { stub_symlink_methods }
|
||||
|
||||
it 'is valid' do
|
||||
FactoryGirl.create(:build_list_package).should be_persisted
|
||||
end
|
||||
|
||||
context '#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
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
it "ensures that valid epoch has been setted" do
|
||||
package.epoch = '55'
|
||||
package.save
|
||||
package.epoch.should == 55
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in New Issue