Sha256: c00dc8ffbf46ccc257c750c83dc2d410b7cc32d5a47fb2c2b75a9b0b54fc224e

Contents?: true

Size: 897 Bytes

Versions: 11

Compression:

Stored size: 897 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 "select with consistency" do
    Issue.with_consistency 'ONE' do
      Issue.all
    end
  end

  test "chaining where with scope" do
    issue = Issue.create title: 'abc', description: 'def'
    query = Issue.select(:title).for_key(issue.id)
    assert_match /^SELECT KEY,title/, query.to_cql
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
gotime-cassandra_object-4.11.6 test/unit/scope/query_methods_test.rb
gotime-cassandra_object-4.11.5 test/unit/scope/query_methods_test.rb
gotime-cassandra_object-4.11.4 test/unit/scope/query_methods_test.rb
gotime-cassandra_object-4.11.3 test/unit/scope/query_methods_test.rb
gotime-cassandra_object-4.11.2 test/unit/scope/query_methods_test.rb
gotime-cassandra_object-4.11.1 test/unit/scope/query_methods_test.rb
gotime-cassandra_object-4.11.0 test/unit/scope/query_methods_test.rb
gotime-cassandra_object-4.10.5 test/unit/scope/query_methods_test.rb
gotime-cassandra_object-4.10.4 test/unit/scope/query_methods_test.rb
gotime-cassandra_object-4.10.3 test/unit/scope/query_methods_test.rb
gotime-cassandra_object-4.10.2 test/unit/scope/query_methods_test.rb