Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## Layout
- [Project] -> [Servers]
- [Project] -> [Job Templates]
- [Job Template] -> {associated servers} -> [Servers]
- {associated servers} contains a `tag` column, if this is = "master" then it should be available to JobTemplate.new().master_server
- ## Job Template
- class JobTemplate < ActiveRecord::Base
- validates_presence_of :description, :project_id
- validates_associated :project
- belongs_to :project
- has_many :associated_servers
- has_one :master_server, :through => :associated_servers, :source => :server, :conditions => ['associated_servers.tag LIKE ?', 'master']
- end
- ## Test (ActiveSupport::TestCase)
- test "having a master server" do
- job_template = Factory( :job_template,
- :associated_servers => [Factory(:associated_server, :tag => 'master'),
- Factory(:associated_server)])
- debugger
- assert_instance_of Server, job_template.master_server
- end
Add Comment
Please, Sign In to add comment