Fix specs, migrate to downcase tags, still testing migration

This commit is contained in:
Raphael Sofaer 2011-03-11 14:22:49 -08:00
parent 8f1a6f502e
commit 7ac3692a92
6 changed files with 55 additions and 8 deletions

View file

@ -25,7 +25,7 @@ gem 'will_paginate', '3.0.pre2'
gem 'i18n-inflector-rails', '~> 1.0'
#Tags
gem 'acts-as-taggable-on', '2.0.6'
gem 'acts-as-taggable-on', :git => 'git://github.com/diaspora/acts-as-taggable-on.git'
#Uncatagorized
gem 'roxml', :git => 'git://github.com/Empact/roxml.git', :ref => '7ea9a9ffd2338aaef5b0'

View file

@ -7,6 +7,19 @@ GIT
activesupport (>= 2.3.0)
nokogiri (>= 1.3.3)
GIT
remote: git://github.com/diaspora/acts-as-taggable-on.git
revision: 498089b41503af633f55bdc1d43b142e7d76e1f1
specs:
acts-as-taggable-on (2.0.6)
jeweler
mysql
pg
rails (>= 3.0)
rcov
rspec (>= 2.0)
sqlite3-ruby
GIT
remote: git://github.com/iain/http_accept_language.git
revision: 0b78aa7849fc90cf9e12586af162fa4c408a795d
@ -86,7 +99,6 @@ GEM
activemodel (= 3.0.3)
activesupport (= 3.0.3)
activesupport (3.0.3)
acts-as-taggable-on (2.0.6)
addressable (2.2.2)
arel (2.0.9)
aws (2.3.32)
@ -190,6 +202,7 @@ GEM
gem_plugin (0.2.3)
gherkin (2.3.3)
json (~> 1.4.6)
git (1.2.5)
haml (3.0.25)
hashie (0.4.0)
highline (1.6.1)
@ -204,6 +217,10 @@ GEM
jammit (0.5.4)
closure-compiler (>= 0.1.0)
yui-compressor (>= 0.9.1)
jeweler (1.5.2)
bundler (~> 1.0.0)
git (>= 1.2.5)
rake
json (1.4.6)
json_pure (1.5.1)
launchy (0.4.0)
@ -232,6 +249,7 @@ GEM
multi_json (0.0.5)
multi_xml (0.2.1)
multipart-post (1.1.0)
mysql (2.8.1)
mysql2 (0.2.6)
net-ldap (0.1.1)
net-scp (1.0.4)
@ -282,6 +300,7 @@ GEM
oa-enterprise (= 0.1.6)
oa-oauth (= 0.1.6)
oa-openid (= 0.1.6)
pg (0.10.1)
polyglot (0.3.1)
pyu-ruby-sasl (0.0.3.2)
rack (1.2.1)
@ -355,6 +374,9 @@ GEM
sinatra (1.2.0)
rack (~> 1.1)
tilt (< 2.0, >= 1.2.2)
sqlite3 (1.3.3)
sqlite3-ruby (1.3.3)
sqlite3 (>= 1.3.3)
subexec (0.0.4)
systemu (1.2.0)
term-ansicolor (1.0.5)
@ -387,7 +409,7 @@ PLATFORMS
DEPENDENCIES
SystemTimer (= 1.2.1)
acts-as-taggable-on (= 2.0.6)
acts-as-taggable-on!
addressable (= 2.2.2)
aws (= 2.3.32)
bundler (>= 1.0.0)

View file

@ -0,0 +1,26 @@
class DowncaseTags < ActiveRecord::Migration
def consolidate_tags_with_name(name)
tags = execute("SELECT * FROM tags WHERE tags.name = ?;", name)
keep_tag = tags.pop
tags.each do |bad_tag|
execute("UPDATE taggings
SET taggings.tag_id = #{keep_tag.first}
WHERE taggings.tag_id = #{bad_tag.first};")
execute("DELETE tags WHERE tags.id = #{bad_tag.first}")
end
end
def self.up
execute('UPDATE tags
SET tags.name = LOWER(tags.name);')
names_with_duplicates = execute('SELECT name FROM tags
GROUP BY name
HAVING COUNT(*)>1;').to_a.flatten!
names_with_duplicates.each do |name|
consolidate_tags_with_name(name)
end unless names_with_duplicates.blank?
end
def self.down
end
end

View file

@ -10,7 +10,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20110311000150) do
ActiveRecord::Schema.define(:version => 20110311220249) do
create_table "aspect_memberships", :force => true do |t|
t.integer "aspect_id", :null => false

View file

@ -180,7 +180,7 @@ STR
end
describe '#format_tags' do
before do
@str = '#what #hey'
@str = '#what #hey'
@sm.message = @str
@sm.build_tags
@sm.save
@ -192,7 +192,6 @@ STR
end
it 'responds to plain_text' do
@sm.format_tags(@str, :plain_text => true).should == @str
end
end
describe '#build_tags' do

View file

@ -245,9 +245,9 @@ describe User do
it 'displays recent posts first' do
msg3 = @user3.post(:status_message, :message => "hey there", :to => 'all', :public => true)
msg4 = @user3.post(:status_message, :message => "hey there", :to => 'all', :public => true)
msg3.updated_at = Time.now+10
msg3.created_at = Time.now+10
msg3.save!
msg4.updated_at = Time.now+14
msg4.created_at = Time.now+14
msg4.save!
@user.posts_from(@user3.person).map{|p| p.id}.should == [msg4, msg3, @public_message].map{|p| p.id}