diary_entry = create(:diary_entry)
diary_comment = create(:diary_comment, :diary_entry => diary_entry)
- issue = Issue.new(:reportable => user, :assigned_role => "administrator")
+ issue = build(:issue, :reportable => user, :assigned_role => "administrator")
issue.save!
assert_equal issue.reported_user, user
- issue = Issue.new(:reportable => note, :assigned_role => "administrator")
+ issue = build(:issue, :reportable => note, :assigned_role => "administrator")
issue.save!
assert_equal issue.reported_user, note.author
- issue = Issue.new(:reportable => anonymous_note, :assigned_role => "administrator")
+ issue = build(:issue, :reportable => anonymous_note, :assigned_role => "administrator")
issue.save!
assert_nil issue.reported_user
- issue = Issue.new(:reportable => diary_entry, :assigned_role => "administrator")
+ issue = build(:issue, :reportable => diary_entry, :assigned_role => "administrator")
issue.save!
assert_equal issue.reported_user, diary_entry.user
- issue = Issue.new(:reportable => diary_comment, :assigned_role => "administrator")
+ issue = build(:issue, :reportable => diary_comment, :assigned_role => "administrator")
issue.save!
assert_equal issue.reported_user, diary_comment.user
end
EURO = "\xe2\x82\xac".freeze # euro symbol
def test_check_empty_message_fails
- message = Message.new
+ message = build(:message, :title => nil, :body => nil, :sent_on => nil)
assert_not message.valid?
assert message.errors[:title].any?
assert message.errors[:body].any?
# Check that you can create a node and store it
def test_create
changeset = create(:changeset)
- node_template = Node.new(
- :lat => 12.3456,
- :lon => 65.4321,
- :changeset_id => changeset.id,
- :visible => 1,
- :version => 1
- )
+ node_template = build(:node, :lat => 12.3456,
+ :lon => 65.4321,
+ :changeset_id => changeset.id,
+ :visible => true,
+ :version => 1)
assert node_template.create_with_history(changeset.user)
node = Node.find(node_template.id)
assert_nil changeset.max_lon
assert_nil changeset.max_lat
assert_nil changeset.min_lat
- new_relation = Relation.new
- new_relation.id = super_relation.id
- new_relation.version = super_relation.version
- new_relation.changeset = changeset
+ new_relation = build(:relation, :id => super_relation.id,
+ :version => super_relation.version,
+ :changeset => changeset)
new_relation.add_member node_member.member_type, node_member.member_id, node_member.member_role
# one member(relation type) was removed, so any_relation flag is expected to be true.
super_relation.update_from(new_relation, user)
assert_nil changeset.max_lat
assert_nil changeset.min_lat
- new_relation = Relation.new
- new_relation.id = orig_relation.id
- new_relation.version = orig_relation.version
- new_relation.changeset_id = changeset.id
+ new_relation = build(:relation, :id => orig_relation.id,
+ :version => orig_relation.version,
+ :changeset_id => changeset.id)
orig_relation.delete_with_history!(new_relation, user)
changeset.reload
assert_equal 39, changeset.min_lon
# Checks that you cannot add a new preference, that is a duplicate
def test_add_duplicate_preference
up = create(:user_preference)
- new_up = UserPreference.new
+ new_up = build(:user_preference)
new_up.user = up.user
new_up.k = up.k
new_up.v = "some other value"
key = "k"
val = "v"
[1, 255].each do |i|
- up = UserPreference.new
+ up = build(:user_preference)
up.user = create(:user)
up.k = key * i
up.v = val * i
key = "k"
val = "v"
[0, 256].each do |i|
- up = UserPreference.new
+ up = build(:user_preference)
up.user = create(:user)
up.k = key * i
up.v = val * i