diff --git a/app/models/person.rb b/app/models/person.rb index 822e6a8..0946f4b 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -8,7 +8,7 @@ class Person < Profile # has_many :people, :through => :person_friendships, :foreign_key => 'friend_id' has_one :person_info -# has_many :role_assignments +# has_many :role_assignments, :as => :accessor, :class_name => 'RoleAssignment' # def has_permission?(perm, res=nil) # return true if res == self && PERMISSIONS[:profile].keys.include?(perm) diff --git a/script/populate b/script/populate index 7a9b084..c854e62 100755 --- a/script/populate +++ b/script/populate @@ -1,14 +1,17 @@ #!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/environment' +Profile.destroy_all anhetegua = Profile.create!(:name => 'noosfero', :identifier => 'noosfero') +User.destroy_all User.create!(:login => 'testprofile', :email => 'admin@localhost.localdomain', :password => 'test', :password_confirmation => 'test') User.create!(:login => 'user', :email => 'user@localhost.localdomain', :password => 'user', :password_confirmation => 'user') User.create!(:login => 'usuario', :email => 'usuario@localhost.localdomain', :password => 'usuario', :password_confirmation => 'usuario') -ze = User.create!(:login => 'ze', :email => 'ze@localhost.localdomain', :password => 'test', :password_confirmation => 'test') +ze = User.create!(:login => 'ze', :email => 'ze@localhost.localdomain', :password => 'test', :password_confirmation => 'test').person root = User.create!(:login => 'root', :email => 'root@noosfero.org', :password => 'root', :password_confirmation => 'root').person +Role.destroy_all admin_role = Role.create!(:name => 'admin', :permissions => ['edit_environment_features', 'edit_environment_design', 'manage_environment_categories', 'manage_environment_roles', 'manage_environment_validators']) RoleAssignment.create!(:accessor => root, :role => admin_role, :resource => nil) diff --git a/script/reset_db b/script/reset_db index 01b77bd..83d6b39 100755 --- a/script/reset_db +++ b/script/reset_db @@ -2,6 +2,7 @@ require File.dirname(__FILE__) + '/../config/environment' system "rm #{RAILS_ROOT}/tmp/*.db" +system "rm #{RAILS_ROOT}/db/*.db" system "rake db:migrate VERSION=0" system "rake db:migrate" system "ruby #{RAILS_ROOT}/script/anhetegua" diff --git a/test/fixtures/role_assignments.yml b/test/fixtures/role_assignments.yml index 6fd194e..a006485 100644 --- a/test/fixtures/role_assignments.yml +++ b/test/fixtures/role_assignments.yml @@ -2,28 +2,28 @@ one: id: 1 accessor_id: 4 - accessor_type: 'Person' + accessor_type: 'Profile' role_id: 2 resource_id: 5 resource_type: 'Profile' two: id: 2 accessor_id: 1 - accessor_type: 'Person' + accessor_type: 'Profile' role_id: 1 resource_id: 5 resource_type: 'Profile' three: id: 3 accessor_id: 1 - accessor_type: 'Person' + accessor_type: 'Profile' role_id: 1 resource_id: 6 resource_type: 'Profile' four: id: 4 accessor_id: 4 - accessor_type: 'Person' + accessor_type: 'Profile' role_id: 4 resource_id: 1 resource_type: 'Environment' diff --git a/test/functional/admin_panel_controller_test.rb b/test/functional/admin_panel_controller_test.rb index 805d718..c960a56 100644 --- a/test/functional/admin_panel_controller_test.rb +++ b/test/functional/admin_panel_controller_test.rb @@ -6,12 +6,12 @@ class AdminPanelController; def rescue_action(e) raise e end; end class AdminPanelControllerTest < Test::Unit::TestCase - fixtures :environments - + all_fixtures def setup @controller = AdminPanelController.new @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new + login_as(:ze) end def test_index diff --git a/test/functional/categories_controller_test.rb b/test/functional/categories_controller_test.rb index 80bcdbb..06da796 100644 --- a/test/functional/categories_controller_test.rb +++ b/test/functional/categories_controller_test.rb @@ -15,6 +15,7 @@ class CategoriesControllerTest < Test::Unit::TestCase Environment.stubs(:default).returns(env) assert (@cat1 = env.categories.create(:name => 'a test category')) assert (@cat1 = env.categories.create(:name => 'another category')) + login_as(:ze) end attr_reader :env, :cat1, :cat2 diff --git a/test/functional/role_controller_test.rb b/test/functional/role_controller_test.rb index 60270c6..bb5e9d0 100644 --- a/test/functional/role_controller_test.rb +++ b/test/functional/role_controller_test.rb @@ -9,11 +9,13 @@ class RoleControllerTest < Test::Unit::TestCase @controller = RoleController.new @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new + login_as(:ze) end all_fixtures def test_index_should_get_roles get 'index' + assert_response :success assert assigns(:roles) end diff --git a/test/test_helper.rb b/test/test_helper.rb index 9495a80..fb91117 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -28,12 +28,13 @@ class Test::Unit::TestCase # Add more helper methods to be used by all tests here... include AuthenticatedTestHelper - + def self.all_fixtures Dir.glob(File.join(RAILS_ROOT, 'test', 'fixtures', '*.yml')).each do |item| fixtures File.basename(item).sub(/\.yml$/, '').to_s end end + all_fixtures def self.should(name, &block) @shoulds ||= [] -- libgit2 0.21.2