Commit b7f9b8223e40aa9e4aa8579d9a062df7e2e1d959
1 parent
f36f0dac
Exists in
master
and in
4 other branches
Fix `search` class method for IssueCommonality
Also adds specs to the two affected classes that would have caught my dumb mistake.
Showing
3 changed files
with
21 additions
and
2 deletions
Show diff stats
app/roles/issue_commonality.rb
| @@ -36,8 +36,10 @@ module IssueCommonality | @@ -36,8 +36,10 @@ module IssueCommonality | ||
| 36 | attr_accessor :author_id_of_changes | 36 | attr_accessor :author_id_of_changes |
| 37 | end | 37 | end |
| 38 | 38 | ||
| 39 | - def self.search query | ||
| 40 | - where("title like :query", :query => "%#{query}%") | 39 | + module ClassMethods |
| 40 | + def search(query) | ||
| 41 | + where("title like :query", :query => "%#{query}%") | ||
| 42 | + end | ||
| 41 | end | 43 | end |
| 42 | 44 | ||
| 43 | def today? | 45 | def today? |
spec/models/issue_spec.rb
| @@ -106,6 +106,14 @@ describe Issue do | @@ -106,6 +106,14 @@ describe Issue do | ||
| 106 | end | 106 | end |
| 107 | end | 107 | end |
| 108 | 108 | ||
| 109 | + describe ".search" do | ||
| 110 | + let!(:issue) { Factory.create(:issue, :title => "Searchable issue", | ||
| 111 | + :project => Factory.create(:project)) } | ||
| 112 | + | ||
| 113 | + it "matches by title" do | ||
| 114 | + Issue.search('able').all.should == [issue] | ||
| 115 | + end | ||
| 116 | + end | ||
| 109 | end | 117 | end |
| 110 | # == Schema Information | 118 | # == Schema Information |
| 111 | # | 119 | # |
spec/models/merge_request_spec.rb
| @@ -56,6 +56,15 @@ describe MergeRequest do | @@ -56,6 +56,15 @@ describe MergeRequest do | ||
| 56 | subject.upvotes.should == 2 | 56 | subject.upvotes.should == 2 |
| 57 | end | 57 | end |
| 58 | end | 58 | end |
| 59 | + | ||
| 60 | + describe ".search" do | ||
| 61 | + let!(:issue) { Factory.create(:issue, :title => "Searchable issue", | ||
| 62 | + :project => Factory.create(:project)) } | ||
| 63 | + | ||
| 64 | + it "matches by title" do | ||
| 65 | + Issue.search('able').all.should == [issue] | ||
| 66 | + end | ||
| 67 | + end | ||
| 59 | end | 68 | end |
| 60 | # == Schema Information | 69 | # == Schema Information |
| 61 | # | 70 | # |