Permalink
Browse files

Give artifact_version a has_one to get to its cloud_profile.

  • Loading branch information...
1 parent 6b6561e commit 9b9f832f14139a750457263eb893065995397c33 @tobias tobias committed Jan 13, 2011
Showing with 4 additions and 4 deletions.
  1. +2 −1 app/models/artifact_version.rb
  2. +2 −3 spec/models/artifact_version_spec.rb
View
3 app/models/artifact_version.rb
@@ -36,7 +36,8 @@ class ArtifactVersion < ActiveRecord::Base
belongs_to :artifact
has_many :deployments, :dependent => :destroy
-
+ has_one :cloud_profile, :through => :artifact
+
before_create :assign_version_number
after_create :upload!
# This before_destroy must come before has_attached_file
View
5 spec/models/artifact_version_spec.rb
@@ -36,9 +36,8 @@
artifact_version.save!
end
- it "should belong to an artifact" do
- ArtifactVersion.new.should respond_to(:artifact)
- end
+ it { should belong_to :artifact }
+ it { should have_one(:cloud_profile).through(:artifact) }
it "should assign a version number before creating" do
artifact_version = ArtifactVersion.new(@valid_attributes)

0 comments on commit 9b9f832

Please sign in to comment.