Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

use all tag in downcase see #34

  • Loading branch information...
commit 3894bc602f6448ef0f22f2485f3181c8d280dc5f 1 parent 30e8ec4
@shingara authored
Showing with 17 additions and 3 deletions.
  1. +4 −3 app/models/ticket.rb
  2. +13 −0 spec/models/ticket_spec.rb
View
7 app/models/ticket.rb
@@ -102,7 +102,7 @@ def generate_update(ticket, user)
t.add_update(:tag_list,
Ticket.list_tag(self.tag_list).join(','),
Ticket.list_tag(ticket[:tag_list]).join(','))
- self.tag_list = ticket[:tag_list]
+ self.tag_list = ticket[:tag_list].try(:downcase)
end
[[:state_id, State],
@@ -146,7 +146,7 @@ def self.paginate_by_search(q, conditions={})
query_conditions[:state_name] = s[1]
elsif s[0] == 'tagged'
query_conditions[:tags] ||= []
- query_conditions[:tags] << s[1]
+ query_conditions[:tags] << s[1].downcase
elsif s[0] == 'closed'
query_conditions[:closed] = (s[1] == 'true')
else
@@ -175,7 +175,7 @@ def self.new_by_params(params, project, user)
def self.list_tag(string)
string.to_s.split(',').map { |name|
- name.gsub(/[^\w_-]/i, '').strip
+ name.gsub(/[^\w_-]/i, '').strip.downcase
}.uniq.sort
end
@@ -253,6 +253,7 @@ def copy_user_creator_name
def update_tags
self.tags = Ticket.list_tag(self.tag_list)
+ self.tag_list = self.tag_list.downcase
end
def update_priority
View
13 spec/models/ticket_spec.rb
@@ -140,6 +140,9 @@ def valid_ticket
Ticket.paginate_by_search("tagged:#{@second_tag} tagged:#{@third_tag}",
:page => 1,
:per_page => 10).sort_by(&:title).should == [@second_ticket, @four_ticket].sort_by(&:title)
+ Ticket.paginate_by_search("tagged:#{@second_tag.upcase} tagged:#{@third_tag.upcase}",
+ :page => 1,
+ :per_page => 10).sort_by(&:title).should == [@second_ticket, @four_ticket].sort_by(&:title)
end
it 'should return all ticket with all tags define by tagged:xxx and state:xxx in query' do
@@ -592,6 +595,16 @@ def new_by_params(args={})
end
end
+
+ describe '#update_tags' do
+ it 'should save in downcase' do
+ Ticket.make(:tag_list => 'foo,bar,baz'.upcase).tags.should == Set.new(['bar','baz','foo'])
+
+ end
+ it 'should split tag_list' do
+ Ticket.make(:tag_list => 'foo,bar,baz').tags.should == Set.new(['bar','baz','foo'])
+ end
+ end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.