Sha256: 93d2be8c205591839c953625aad72ba3202beeed73ed4516cc18060a85e240e6
Contents?: true
Size: 1.1 KB
Versions: 8
Compression:
Stored size: 1.1 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' 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
8 entries across 8 versions & 1 rubygems