Commit d1b3f21894841bbdd5d0117a8477d39f52cf9e95
1 parent
11212b3f
Exists in
master
and in
29 other branches
ActionItem111: fixed some tests
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@749 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
8 changed files
with
17 additions
and
9 deletions
Show diff stats
app/models/person.rb
... | ... | @@ -8,7 +8,7 @@ class Person < Profile |
8 | 8 | # has_many :people, :through => :person_friendships, :foreign_key => 'friend_id' |
9 | 9 | |
10 | 10 | has_one :person_info |
11 | -# has_many :role_assignments | |
11 | +# has_many :role_assignments, :as => :accessor, :class_name => 'RoleAssignment' | |
12 | 12 | |
13 | 13 | # def has_permission?(perm, res=nil) |
14 | 14 | # return true if res == self && PERMISSIONS[:profile].keys.include?(perm) | ... | ... |
script/populate
1 | 1 | #!/usr/bin/env ruby |
2 | 2 | require File.dirname(__FILE__) + '/../config/environment' |
3 | 3 | |
4 | +Profile.destroy_all | |
4 | 5 | anhetegua = Profile.create!(:name => 'noosfero', :identifier => 'noosfero') |
5 | 6 | |
7 | +User.destroy_all | |
6 | 8 | User.create!(:login => 'testprofile', :email => 'admin@localhost.localdomain', :password => 'test', :password_confirmation => 'test') |
7 | 9 | User.create!(:login => 'user', :email => 'user@localhost.localdomain', :password => 'user', :password_confirmation => 'user') |
8 | 10 | User.create!(:login => 'usuario', :email => 'usuario@localhost.localdomain', :password => 'usuario', :password_confirmation => 'usuario') |
9 | -ze = User.create!(:login => 'ze', :email => 'ze@localhost.localdomain', :password => 'test', :password_confirmation => 'test') | |
11 | +ze = User.create!(:login => 'ze', :email => 'ze@localhost.localdomain', :password => 'test', :password_confirmation => 'test').person | |
10 | 12 | root = User.create!(:login => 'root', :email => 'root@noosfero.org', :password => 'root', :password_confirmation => 'root').person |
11 | 13 | |
14 | +Role.destroy_all | |
12 | 15 | admin_role = Role.create!(:name => 'admin', :permissions => ['edit_environment_features', 'edit_environment_design', 'manage_environment_categories', 'manage_environment_roles', 'manage_environment_validators']) |
13 | 16 | |
14 | 17 | RoleAssignment.create!(:accessor => root, :role => admin_role, :resource => nil) | ... | ... |
script/reset_db
test/fixtures/role_assignments.yml
... | ... | @@ -2,28 +2,28 @@ |
2 | 2 | one: |
3 | 3 | id: 1 |
4 | 4 | accessor_id: 4 |
5 | - accessor_type: 'Person' | |
5 | + accessor_type: 'Profile' | |
6 | 6 | role_id: 2 |
7 | 7 | resource_id: 5 |
8 | 8 | resource_type: 'Profile' |
9 | 9 | two: |
10 | 10 | id: 2 |
11 | 11 | accessor_id: 1 |
12 | - accessor_type: 'Person' | |
12 | + accessor_type: 'Profile' | |
13 | 13 | role_id: 1 |
14 | 14 | resource_id: 5 |
15 | 15 | resource_type: 'Profile' |
16 | 16 | three: |
17 | 17 | id: 3 |
18 | 18 | accessor_id: 1 |
19 | - accessor_type: 'Person' | |
19 | + accessor_type: 'Profile' | |
20 | 20 | role_id: 1 |
21 | 21 | resource_id: 6 |
22 | 22 | resource_type: 'Profile' |
23 | 23 | four: |
24 | 24 | id: 4 |
25 | 25 | accessor_id: 4 |
26 | - accessor_type: 'Person' | |
26 | + accessor_type: 'Profile' | |
27 | 27 | role_id: 4 |
28 | 28 | resource_id: 1 |
29 | 29 | resource_type: 'Environment' | ... | ... |
test/functional/admin_panel_controller_test.rb
... | ... | @@ -6,12 +6,12 @@ class AdminPanelController; def rescue_action(e) raise e end; end |
6 | 6 | |
7 | 7 | class AdminPanelControllerTest < Test::Unit::TestCase |
8 | 8 | |
9 | - fixtures :environments | |
10 | - | |
9 | + all_fixtures | |
11 | 10 | def setup |
12 | 11 | @controller = AdminPanelController.new |
13 | 12 | @request = ActionController::TestRequest.new |
14 | 13 | @response = ActionController::TestResponse.new |
14 | + login_as(:ze) | |
15 | 15 | end |
16 | 16 | |
17 | 17 | def test_index | ... | ... |
test/functional/categories_controller_test.rb
... | ... | @@ -15,6 +15,7 @@ class CategoriesControllerTest < Test::Unit::TestCase |
15 | 15 | Environment.stubs(:default).returns(env) |
16 | 16 | assert (@cat1 = env.categories.create(:name => 'a test category')) |
17 | 17 | assert (@cat1 = env.categories.create(:name => 'another category')) |
18 | + login_as(:ze) | |
18 | 19 | end |
19 | 20 | attr_reader :env, :cat1, :cat2 |
20 | 21 | ... | ... |
test/functional/role_controller_test.rb
... | ... | @@ -9,11 +9,13 @@ class RoleControllerTest < Test::Unit::TestCase |
9 | 9 | @controller = RoleController.new |
10 | 10 | @request = ActionController::TestRequest.new |
11 | 11 | @response = ActionController::TestResponse.new |
12 | + login_as(:ze) | |
12 | 13 | end |
13 | 14 | all_fixtures |
14 | 15 | |
15 | 16 | def test_index_should_get_roles |
16 | 17 | get 'index' |
18 | + assert_response :success | |
17 | 19 | assert assigns(:roles) |
18 | 20 | end |
19 | 21 | ... | ... |
test/test_helper.rb
... | ... | @@ -28,12 +28,13 @@ class Test::Unit::TestCase |
28 | 28 | # Add more helper methods to be used by all tests here... |
29 | 29 | |
30 | 30 | include AuthenticatedTestHelper |
31 | - | |
31 | + | |
32 | 32 | def self.all_fixtures |
33 | 33 | Dir.glob(File.join(RAILS_ROOT, 'test', 'fixtures', '*.yml')).each do |item| |
34 | 34 | fixtures File.basename(item).sub(/\.yml$/, '').to_s |
35 | 35 | end |
36 | 36 | end |
37 | + all_fixtures | |
37 | 38 | |
38 | 39 | def self.should(name, &block) |
39 | 40 | @shoulds ||= [] | ... | ... |