File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,9 +2,8 @@ class Tag < ActiveRecord::Base
22 has_many :taggings
33 has_many :users , through : :taggings , source : :user
44
5- scope :fetch_list_by_tag_name , -> ( tag_name ) {
5+ scope :fetch_list_by_tag_name , -> ( tag_name ) {
66 tag_arel = Tag . arel_table
77 where ( tag_arel [ :tag_name ] . matches ( "%#{ tag_name } %" ) )
88 }
9-
10- end
9+ end
Original file line number Diff line number Diff line change 3030
3131 config . include ShowMeTheCookies , :type => :feature
3232
33+ config . before ( :suite ) do
34+ DatabaseCleaner . strategy = :transaction
35+ DatabaseCleaner . clean_with ( :truncation )
36+ end
37+
38+ config . around ( :each ) do |example |
39+ DatabaseCleaner . cleaning do
40+ example . run
41+ end
42+ end
43+
3344 # If you're not using ActiveRecord, or you'd prefer not to run each of your
3445 # examples within a transaction, remove the following line or assign false
3546 # instead of true.
Original file line number Diff line number Diff line change 1+ require "rails_helper"
2+
3+ RSpec . describe Tag , :type => :model do
4+ describe "#fetch_list_by_tag_name" do
5+ it "should fetch tag list where like name" do
6+ tag1 = Tag . create! ( tag_name : "Hello" )
7+ tag2 = Tag . create! ( tag_name : "World" )
8+ tag3 = Tag . create! ( tag_name : "Yellow" )
9+
10+ expect ( Tag . fetch_list_by_tag_name ( "Worl" ) ) . to contain_exactly ( tag2 )
11+ expect ( Tag . fetch_list_by_tag_name ( "llo" ) ) . to contain_exactly ( tag1 , tag3 )
12+ end
13+ end
14+ end
You can’t perform that action at this time.
0 commit comments