Guest User

Untitled

a guest
Jul 16th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. ## Layout
  2.  
  3. [Project] -> [Servers]
  4. [Project] -> [Job Templates]
  5. [Job Template] -> {associated servers} -> [Servers]
  6.  
  7. {associated servers} contains a `tag` column, if this is = "master" then it should be available to JobTemplate.new().master_server
  8.  
  9. ## Job Template
  10. class JobTemplate < ActiveRecord::Base
  11.  
  12. validates_presence_of :description, :project_id
  13.  
  14. validates_associated :project
  15.  
  16. belongs_to :project
  17.  
  18. has_many :associated_servers
  19. has_one :master_server, :through => :associated_servers, :source => :server, :conditions => ['associated_servers.tag LIKE ?', 'master']
  20.  
  21. end
  22.  
  23. ## Test (ActiveSupport::TestCase)
  24. test "having a master server" do
  25. job_template = Factory( :job_template,
  26. :associated_servers => [Factory(:associated_server, :tag => 'master'),
  27. Factory(:associated_server)])
  28. debugger
  29. assert_instance_of Server, job_template.master_server
  30. end
Add Comment
Please, Sign In to add comment