diff --git a/lib/tasks/migration.rb b/lib/tasks/migrations.rake similarity index 94% rename from lib/tasks/migration.rb rename to lib/tasks/migrations.rake index a79c32741462d2badafeaad7788bcd9d235bc72f..eb839746cb49ba2e27291c993a62ae5c0b88f8cb 100644 --- a/lib/tasks/migration.rb +++ b/lib/tasks/migrations.rake @@ -1,4 +1,4 @@ -namespace :migration do +namespace :migrations do desc 'make old registered services into the new class specific services' task :service_reclassify do Service.all.each do |s| diff --git a/spec/lib/tasks/migrations_spec.rb b/spec/lib/tasks/migrations_spec.rb new file mode 100644 index 0000000000000000000000000000000000000000..42e8c9c6108aa7b3d82b071775a47857efc0135b --- /dev/null +++ b/spec/lib/tasks/migrations_spec.rb @@ -0,0 +1,30 @@ +# Copyright (c) 2010, Diaspora Inc. This file is +# licensed under the Affero General Public License version 3 or later. See +# the COPYRIGHT file. + +require 'spec_helper' +require File.join(Rails.root, 'lib/hcard') + +describe 'migrations' do + + + describe 'service_reclassify' do + it 'makes classless servcices have class' do + s1 = Service.new(:access_token => "foo", :access_secret => "barbar", :provider => "facebook") + s2 = Service.new(:access_token => "foo", :access_secret => "barbar", :provider => "twitter") + s1.save + s2.save + + require "rake" + @rake = Rake::Application.new + Rake.application = @rake + Rake.application.rake_require "lib/tasks/migrations" + Rake::Task.define_task(:environment) + @rake['migrations:service_reclassify'].invoke + + Service.all.any?{|x| x.class.name == "Services::Twitter"}.should be true + Service.all.any?{|x| x.class.name == "Services::Facebook"}.should be true + end + end +end +