Sha256: 8b273ba83bfbb26e3844ba0f0e95490e3155bf9107c9b5fa473186b0ab52c6b7

Contents?: true

Size: 1.35 KB

Versions: 12

Compression:

Stored size: 1.35 KB

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 'multi select' do
    original_issue = Issue.create title: 'foo', description: 'bar'
    found_issue =  Issue.select(:title, :description).find(original_issue.id)

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

  test 'select with block' do
    foo_issue = Issue.create title: 'foo'
    Issue.create title: 'bar'
    assert_equal [foo_issue], Issue.find_all_in_batches[:results].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

  test 'only column names' do
    Issue.create title: 'foo', description: 'bar'
    foo_issue_columns =  Issue.columns.first
    assert_equal ['created_at', 'description', 'title', 'updated_at'], foo_issue_columns[foo_issue_columns.keys.first]
  end

end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
extendi-cassandra_object-1.0.18 test/unit/scope/query_methods_test.rb
extendi-cassandra_object-1.0.17 test/unit/scope/query_methods_test.rb
extendi-cassandra_object-1.0.16 test/unit/scope/query_methods_test.rb
extendi-cassandra_object-1.0.15 test/unit/scope/query_methods_test.rb
extendi-cassandra_object-1.0.14 test/unit/scope/query_methods_test.rb
extendi-cassandra_object-1.0.13 test/unit/scope/query_methods_test.rb
extendi-cassandra_object-1.0.12 test/unit/scope/query_methods_test.rb
extendi-cassandra_object-1.0.11 test/unit/scope/query_methods_test.rb
extendi-cassandra_object-1.0.10 test/unit/scope/query_methods_test.rb
extendi-cassandra_object-1.0.9 test/unit/scope/query_methods_test.rb
extendi-cassandra_object-1.0.8 test/unit/scope/query_methods_test.rb
extendi-cassandra_object-1.0.7 test/unit/scope/query_methods_test.rb