Sha256: 3e450cae1193eea46b39b50d954dc3a70fb515548e44e9bc29542c1a9daa052c
Contents?: true
Size: 1.09 KB
Versions: 4
Compression:
Stored size: 1.09 KB
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 "where" do foo_issue = Issue.create title: 'foo' bar_issue = Issue.create title: 'bar' nil_issue = Issue.create title: nil assert_equal [foo_issue], Issue.where(title: 'foo').to_a assert_equal [foo_issue, bar_issue], Issue.where(title: ['foo', 'bar']).to_a assert_equal [nil_issue], Issue.where(title: nil).to_a end test "select with block" do foo_issue = Issue.create title: 'foo' 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
4 entries across 4 versions & 1 rubygems