spec/unit/repository/transaction_spec.rb in rom-repository-1.0.0.beta3 vs spec/unit/repository/transaction_spec.rb in rom-repository-1.0.0.rc1

- old
+ new

@@ -2,11 +2,11 @@ let(:user_repo) do Class.new(ROM::Repository[:users]) { commands :create }.new(rom) end let(:task_repo) do - Class.new(ROM::Repository[:tasks]) { commands :create }.new(rom) + Class.new(ROM::Repository[:tasks]) { commands :create, :update }.new(rom) end include_context 'database' include_context 'relations' @@ -22,7 +22,21 @@ end expect(user.name).to eql('Jane') expect(task.user_id).to be(user.id) expect(task.title).to eql('Task One') + end + + it 'updating tasks user' do + jane = user_repo.create(name: 'Jane') + john = user_repo.create(name: 'John') + task = task_repo.create(title: 'Jane Task', user_id: jane.id) + + task = task_repo.transaction do + task_changeset = task_repo.changeset(task.id, title: 'John Task').associate(john, :user).commit + task_repo.update(task_changeset) + end + + expect(task.user_id).to be(john.id) + expect(task.title).to eql('John Task') end end