Skip to content

Commit

Permalink
Replace changeset_tags fixtures with a factory.
Browse files Browse the repository at this point in the history
  • Loading branch information
gravitystorm committed Oct 30, 2016
1 parent 48eb8eb commit 596494a
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Metrics/BlockNesting:
# Offense count: 62
# Configuration parameters: CountComments.
Metrics/ClassLength:
Max: 1652
Max: 1653

# Offense count: 69
Metrics/CyclomaticComplexity:
Expand Down
1 change: 1 addition & 0 deletions test/controllers/changeset_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1649,6 +1649,7 @@ def test_changeset_update

## Now try with the public user
changeset = changesets(:public_user_first_change)
create(:changeset_tag, :changeset => changeset)
new_changeset = changeset.to_xml
new_tag = XML::Node.new "tag"
new_tag["k"] = "tagtesting"
Expand Down
9 changes: 9 additions & 0 deletions test/factories/changeset_tags.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FactoryGirl.define do
factory :changeset_tag do
sequence(:k) { |n| "Key #{n}" }
sequence(:v) { |n| "Value #{n}" }

# Fixme requires changeset factory
changeset_id 1
end
end
9 changes: 0 additions & 9 deletions test/fixtures/changeset_tags.yml

This file was deleted.

11 changes: 4 additions & 7 deletions test/models/changeset_tag_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
class ChangesetTagTest < ActiveSupport::TestCase
api_fixtures

def test_changeset_tag_count
assert_equal 2, ChangesetTag.count
end

def test_length_key_valid
key = "k"
(0..255).each do |i|
Expand Down Expand Up @@ -58,10 +54,11 @@ def test_empty_tag_invalid
end

def test_uniqueness
existing = create(:changeset_tag)
tag = ChangesetTag.new
tag.changeset_id = changeset_tags(:changeset_1_tag_1).changeset_id
tag.k = changeset_tags(:changeset_1_tag_1).k
tag.v = changeset_tags(:changeset_1_tag_1).v
tag.changeset_id = existing.changeset_id
tag.k = existing.k
tag.v = existing.v
assert tag.new_record?
assert !tag.valid?
assert_raise(ActiveRecord::RecordInvalid) { tag.save! }
Expand Down
2 changes: 1 addition & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class TestCase
def self.api_fixtures
# print "setting up the api_fixtures"
fixtures :users, :user_roles
fixtures :changesets, :changeset_tags
fixtures :changesets

fixtures :current_nodes, :nodes
set_fixture_class :current_nodes => Node
Expand Down

0 comments on commit 596494a

Please sign in to comment.