Sha256: b671e48fe2d6ba202f722f6ca0fff8506f3bcb89bb47ae29bfb5c5dc71c344b8
Contents?: true
Size: 1.23 KB
Versions: 3
Compression:
Stored size: 1.23 KB
Contents
# frozen_string_literal: true require "test_helper" class NodeModelPersistenceTest < Minitest::Test include TestHelpers GRAPH = Redgraph::Graph.new("movies", url: $REDIS_URL) def setup @graph = GRAPH end def teardown @graph.delete end # test classes # class Film include Redgraph::NodeModel self.graph = GRAPH attribute :name end # tests # def test_save_new assert_equal(0, Film.count) film = Film.new(name: "Star Wars") film.save assert_predicate(film, :persisted?) assert_equal(1, Film.count) end def test_save_existing film = Film.create(name: "Star Wars") film.name = "Commando" film.save assert_equal(1, Film.count) item = Film.find(film.id) assert_equal("Commando", item.name) end def test_reload film = Film.create(name: "Star Wars") copy = Film.find(film.id) assert_equal("Star Wars", copy.name) film.name = "Commando" film.save assert_equal("Star Wars", copy.name) assert_equal("Commando", copy.reload.name) end def test_destroy film = Film.create(name: "Star Wars") assert_equal(1, Film.count) film.destroy assert_predicate(film, :destroyed?) assert_equal(0, Film.count) end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
redgraph-0.2.3 | test/node_model_persistence_test.rb |
redgraph-0.2.2 | test/node_model_persistence_test.rb |
redgraph-0.2.1 | test/node_model_persistence_test.rb |