Namespace i testy

Witam,

Natknąłem się na następujący problem - chciałem przenieść stworzony do tej pory kod do namespacea admin, o ile z przeprowadzka kontrolerow i widokow nie bylo problemu to z testami mam problem. przerzucam testy z np z

test/functional

do

test/functional/admin

początek przykładowego testu

[code=ruby]require File.dirname(FILE) + ‘/…/…/test_helper’
require ‘globalize/translation’

class Admin::ProjectsControllerTest < ActionController::TestCase[/code]
w momencie odpalenia testu dzieje się to:

ruby test/functional/admin/projects_controller_test.rb /usr/lib64/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/dependencies.rb:443:in `load_missing_constant': uninitialized constant ApplicationController (NameError) from /usr/lib64/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/dependencies.rb:80:in `const_missing' from /usr/lib64/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/dependencies.rb:92:in `const_missing' from /var/www/localhost/htdocs/unlink_homepage/app/controllers/admin/project_images_controller.rb:1 from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from /usr/lib64/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/dependencies.rb:158:in `require' from /usr/lib64/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/dependencies.rb:265:in `require_or_load' from /usr/lib64/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/dependencies.rb:224:in `depend_on' from /usr/lib64/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/dependencies.rb:136:in `require_dependency' from /usr/lib64/ruby/gems/1.8/gems/rails-2.3.3/lib/initializer.rb:414:in `load_application_classes' from /usr/lib64/ruby/gems/1.8/gems/rails-2.3.3/lib/initializer.rb:413:in `each' from /usr/lib64/ruby/gems/1.8/gems/rails-2.3.3/lib/initializer.rb:413:in `load_application_classes' from /usr/lib64/ruby/gems/1.8/gems/rails-2.3.3/lib/initializer.rb:411:in `each' from /usr/lib64/ruby/gems/1.8/gems/rails-2.3.3/lib/initializer.rb:411:in `load_application_classes' from /usr/lib64/ruby/gems/1.8/gems/rails-2.3.3/lib/initializer.rb:197:in `process' from /usr/lib64/ruby/gems/1.8/gems/rails-2.3.3/lib/initializer.rb:113:in `send' from /usr/lib64/ruby/gems/1.8/gems/rails-2.3.3/lib/initializer.rb:113:in `run' from /var/www/localhost/htdocs/unlink_homepage/config/environment.rb:11 from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from ./test/functional/admin/../../test_helper.rb:2 from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from test/functional/admin/projects_controller_test.rb:1
googlowalem trochę, niestety bezskutecznie

Pierwsza linijka wygląda dziwnie:
/usr/lib64/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/dependencies.rb:443:in `load_missing_constant’: uninitialized constant ApplicationController (NameError)

Taki błąd pierwsze widzę, a robiło się już kilka aplikacji z przestrzeniami nazw dla kontrolerów :confused:
W sensie, nie ładować ApplicationControllera? Dziwne.

Poka pliki i linijki z aplikacji, o które się rozbija. czyli
from /var/www/localhost/htdocs/unlink_homepage/app/controllers/admin/project_images_controller.rb:1
from /var/www/localhost/htdocs/unlink_homepage/config/environment.rb:11

EDIT:
dobra znalazłem przyczynę błędy w kodzie poniżej było ApplicationController zamiast Admin::ApplicationController (kontroler application_controller.rb przenioslem do app/controllers/admin)

app/controllers/admin/project_images_controller.rb

[code=ruby]class Admin::ProjectImagesController < Admin::ApplicationController
before_filter :protect
def delete
@image = ProjectImage.find(params[:id])
@image.destroy
respond_to do |format|
format.html do
flash[:notice] = ‘Zdjęcie zostało usunięte’
redirect_to(:controller => ‘projects’, :action => ‘show’, :id => @image.project.id)
end
format.xml { head :ok }
format.js do
render :update do |page|
page.hide “asset_#{@image.id}”
end
end
end
end

def upload
@project_image = ProjectImage.new(params[:project_image])
@project = Project.find(params[:project_id])
@project_image.project = @project
respond_to do |format|
if @project_image.save
format.html { redirect_to(@project) }
format.js do
responds_to_parent do
render :update do |page|
page.insert_html :bottom, “images_for_project_#{params[:project_id]}”, :partial => ‘ibox’, :object => @project_image
page.visual_effect :highlight, “asset_#{@project_image.id}”
end
end
end
else
format.html { redirect_to(@project_image.project) }
format.js do
render :update do |page|
page.replace_html “image_box”, error_messages_for(:project_image)
end
end
end
end
end
end[/code]
config/environment.rb

[code=ruby]RAILS_GEM_VERSION = ‘2.3.3’ unless defined? RAILS_GEM_VERSION
require File.join(File.dirname(FILE), ‘boot’)
require ‘extensions’
require ‘digest/sha2’

Rails::Initializer.run do |config|
config.time_zone = ‘UTC’
config.action_view[:debug_rjs] = true
config.i18n.default_locale = :pl
end[/code]