Sha256: d0fa3483129a9de6ab053a7f89e8db3451a777aba1933822ae7d22db161e1b6d

Contents?: true

Size: 892 Bytes

Versions: 7

Compression:

Stored size: 892 Bytes

Contents

require 'test_helper'

class TestFileMount < UserTest
  should "start with an empty uploader field" do
    empty = User.new
    assert_true empty.avatar.blank?
  end

  should "create an uploader when given a file" do
    non_empty = User.new
    non_empty.avatar = FileLike.new
    assert_false non_empty.avatar.blank?
  end

  should "save persist attachment id only" do
    u = User.new
    u.avatar = FileLike.new
    assert_not_nil u.avatar.id, "attachment id generated"
    assert_equal u.read_attribute(:avatar), u.avatar.id, "attachment id saved to db"
  end

  should "save and load attachment id to db" do
    u = User.new
    u.avatar = FileLike.new
    u.save!

    loaded = User.find(u.id)
    assert_equal loaded.read_attribute(:avatar), u.avatar.id, "Loaded avatar id from db"
    assert_equal loaded.avatar.id, u.avatar.id, "Loaded avatar id matches the saved one."
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
progstr-filer-0.8.7 test/test_file_mount.rb
progstr-filer-0.8.6 test/test_file_mount.rb
progstr-filer-0.8.5 test/test_file_mount.rb
progstr-filer-0.8.4 test/test_file_mount.rb
progstr-filer-0.8.3 test/test_file_mount.rb
progstr-filer-0.8.2 test/test_file_mount.rb
progstr-filer-0.8.1 test/test_file_mount.rb