Sha256: f308ddfef8636ca6e61139ba26f0fd745015ec88ebed8751a81b7ecd51c571c9

Contents?: true

Size: 781 Bytes

Versions: 18

Compression:

Stored size: 781 Bytes

Contents

require 'test_helper'

class Superstore::Scope::QueryMethodsTest < Superstore::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

18 entries across 18 versions & 1 rubygems

Version Path
superstore-1.2.0 test/unit/scope/query_methods_test.rb
superstore-1.1.4 test/unit/scope/query_methods_test.rb
superstore-1.1.3 test/unit/scope/query_methods_test.rb
superstore-1.1.2 test/unit/scope/query_methods_test.rb
superstore-1.1.1 test/unit/scope/query_methods_test.rb
superstore-1.1.0 test/unit/scope/query_methods_test.rb
superstore-1.0.12 test/unit/scope/query_methods_test.rb
superstore-1.0.11 test/unit/scope/query_methods_test.rb
superstore-1.0.10 test/unit/scope/query_methods_test.rb
superstore-1.0.9 test/unit/scope/query_methods_test.rb
superstore-1.0.8 test/unit/scope/query_methods_test.rb
superstore-1.0.7 test/unit/scope/query_methods_test.rb
superstore-1.0.6 test/unit/scope/query_methods_test.rb
superstore-1.0.5 test/unit/scope/query_methods_test.rb
superstore-1.0.4 test/unit/scope/query_methods_test.rb
superstore-1.0.3 test/unit/scope/query_methods_test.rb
superstore-1.0.2 test/unit/scope/query_methods_test.rb
superstore-1.0.0 test/unit/scope/query_methods_test.rb