-
-
Save kimh/48962ea40dc048565dd2 to your computer and use it in GitHub Desktop.
Assigne false becomes always nil
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'lotus/model' | |
require 'sequel' | |
require 'sqlite3' | |
require 'minitest/autorun' | |
require 'pp' | |
class Item | |
include Lotus::Entity | |
self.attributes = :sold | |
end | |
class ItemRepository | |
include Lotus::Repository | |
end | |
describe "taste field is not mapped" do | |
before(:each) do | |
uri = "sqlite:///tmp/test.db" | |
Lotus::Model.configure do | |
adapter type: :sql, uri: uri, default: true | |
mapping do | |
collection :items do | |
entity Item | |
attribute :id, Integer | |
attribute :sold, Boolean | |
end | |
end | |
end | |
database = Sequel.connect(uri) | |
database.drop_table? :items | |
database.create_table :items do | |
primary_key :id | |
Boolean :sold | |
end | |
Lotus::Model.load! | |
end | |
it 'setting sold field to false is nil' do | |
ItemRepository.create(Item.new(sold: false)) | |
ItemRepository.first.sold.must_be_nil | |
end | |
it 'but setting to true works' do | |
ItemRepository.create(Item.new(sold: true)) | |
ItemRepository.first.sold.must_equal true | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment