Sha256: 4de1211ea0ac791d5fb6e193e1d6f8a68e8b6f8eb8f5f4571078bf55e6feaa85

Contents?: true

Size: 791 Bytes

Versions: 2

Compression:

Stored size: 791 Bytes

Contents

require 'test_helper'

class CassandraObject::Scope::QueryMethodsTest < CassandraObject::TestCase
  test "select" do
    original_issue = Issue.create title: 'foo', description: 'bar'

    found_issue = Issue.select(:title).find(original_issue.id)

    assert_equal 'foo', found_issue.title
    assert_equal original_issue.id, found_issue.id
    assert_nil found_issue.description
  end

  test "select with block" do
    foo_issue = Issue.create title: 'foo'
    bar_issue = Issue.create title: 'bar'

    assert_equal [foo_issue], Issue.select { |issue| issue.title == 'foo' }
  end

  test "chaining where with scope" do
    issue = Issue.create title: 'abc', description: 'def'
    query = Issue.select(:title).for_key(issue.id)

    assert_equal [:title], query.select_values
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gotime-cassandra_object-4.12.2 test/unit/scope/query_methods_test.rb
gotime-cassandra_object-4.12.1 test/unit/scope/query_methods_test.rb