diff options
author | 2011-02-25 20:21:50 +0100 | |
---|---|---|
committer | 2011-02-25 20:21:50 +0100 | |
commit | 0f84779616d454f69f74002d3d754c2043381da9 (patch) | |
tree | e7295560eccb40b7a77d515fc529913b0597ce39 /test/unit | |
parent | Add CVE#url method to get links to CVE info (NVD and MITRE currently) (diff) | |
download | glsamaker-0f84779616d454f69f74002d3d754c2043381da9.tar.gz glsamaker-0f84779616d454f69f74002d3d754c2043381da9.tar.bz2 glsamaker-0f84779616d454f69f74002d3d754c2043381da9.zip |
Add a deep_copy method to the Revision model
The method copies all linked models (bugs, packages, revisions) as well.
Adding some extra fixtures to test this
Diffstat (limited to 'test/unit')
-rw-r--r-- | test/unit/revision_test.rb | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/test/unit/revision_test.rb b/test/unit/revision_test.rb index f50f1af..8514302 100644 --- a/test/unit/revision_test.rb +++ b/test/unit/revision_test.rb @@ -1,8 +1,30 @@ require 'test_helper' class RevisionTest < ActiveSupport::TestCase - # Replace this with your real tests. - test "the truth" do - assert true + test "deep copy" do + revision = revisions(:revision_one) + new_revision = revision.deep_copy + + assert_equal(revision.title, new_revision.title) + assert_equal(revision.glsa_id, new_revision.glsa_id) + assert_equal(revision.access, new_revision.access) + assert_equal(revision.product, new_revision.product) + assert_equal(revision.category, new_revision.category) + assert_equal(revision.severity, new_revision.severity) + assert_equal(revision.synopsis, new_revision.synopsis) + assert_equal(revision.background, new_revision.background) + assert_equal(revision.description, new_revision.description) + assert_equal(revision.impact, new_revision.impact) + assert_equal(revision.workaround, new_revision.workaround) + assert_equal(revision.resolution, new_revision.resolution) + + # Assuming that if the bug ID is copied, so is the rest + assert_equal(revision.bugs.map{|bug| bug.bug_id}.sort, new_revision.bugs.map{|bug| bug.bug_id}.sort) + + assert_equal(revision.references.map{|ref| ref.url}.sort, new_revision.references.map{|ref| ref.url}.sort) + assert_equal( + revision.packages.map{|pkg| "#{pkg.comp}#{pkg.atom}-#{pkg.version}"}.sort, + new_revision.packages.map{|pkg| "#{pkg.comp}#{pkg.atom}-#{pkg.version}"}.sort + ) end end |