Commit 09dd907e38cd60d77f8c42254db0916766465203
1 parent
9f26e921
Exists in
master
and in
29 other branches
Just changing the tempalates named_scope to receive environment instead of environment_id
Showing
4 changed files
with
8 additions
and
8 deletions
Show diff stats
app/helpers/application_helper.rb
@@ -1330,7 +1330,7 @@ module ApplicationHelper | @@ -1330,7 +1330,7 @@ module ApplicationHelper | ||
1330 | end | 1330 | end |
1331 | 1331 | ||
1332 | def template_options(klass, field_name) | 1332 | def template_options(klass, field_name) |
1333 | - templates = klass.templates(environment.id) | 1333 | + templates = klass.templates(environment) |
1334 | return '' if templates.count == 0 | 1334 | return '' if templates.count == 0 |
1335 | return hidden_field_tag("#{field_name}[template_id]", templates.first.id) if templates.count == 1 | 1335 | return hidden_field_tag("#{field_name}[template_id]", templates.first.id) if templates.count == 1 |
1336 | 1336 |
app/models/profile.rb
@@ -68,7 +68,7 @@ class Profile < ActiveRecord::Base | @@ -68,7 +68,7 @@ class Profile < ActiveRecord::Base | ||
68 | #FIXME: these will work only if the subclass is already loaded | 68 | #FIXME: these will work only if the subclass is already loaded |
69 | named_scope :enterprises, lambda { {:conditions => (Enterprise.send(:subclasses).map(&:name) << 'Enterprise').map { |klass| "profiles.type = '#{klass}'"}.join(" OR ")} } | 69 | named_scope :enterprises, lambda { {:conditions => (Enterprise.send(:subclasses).map(&:name) << 'Enterprise').map { |klass| "profiles.type = '#{klass}'"}.join(" OR ")} } |
70 | named_scope :communities, lambda { {:conditions => (Community.send(:subclasses).map(&:name) << 'Community').map { |klass| "profiles.type = '#{klass}'"}.join(" OR ")} } | 70 | named_scope :communities, lambda { {:conditions => (Community.send(:subclasses).map(&:name) << 'Community').map { |klass| "profiles.type = '#{klass}'"}.join(" OR ")} } |
71 | - named_scope :templates, lambda { |environment_id| { :conditions => {:is_template => true, :environment_id => environment_id} } } | 71 | + named_scope :templates, lambda { |environment| { :conditions => {:is_template => true, :environment_id => environment.id} } } |
72 | 72 | ||
73 | def members | 73 | def members |
74 | scopes = plugins.dispatch_scopes(:organization_members, self) | 74 | scopes = plugins.dispatch_scopes(:organization_members, self) |
app/views/templates/index.html.erb
@@ -2,9 +2,9 @@ | @@ -2,9 +2,9 @@ | ||
2 | 2 | ||
3 | <%= _('Manage the templates used on creation of profiles') %> | 3 | <%= _('Manage the templates used on creation of profiles') %> |
4 | 4 | ||
5 | -<% list_of_templates = [[_('Person') , Person.templates(environment.id) , 'person' ], | ||
6 | - [_('Community') , Community.templates(environment.id) , 'community' ], | ||
7 | - [_('Enterprise'), Enterprise.templates(environment.id), 'enterprise']] %> | 5 | +<% list_of_templates = [[_('Person') , Person.templates(environment) , 'person' ], |
6 | + [_('Community') , Community.templates(environment) , 'community' ], | ||
7 | + [_('Enterprise'), Enterprise.templates(environment), 'enterprise']] %> | ||
8 | 8 | ||
9 | <% list_of_templates.each do |title, templates, kind|%> | 9 | <% list_of_templates.each do |title, templates, kind|%> |
10 | <div class='template-kind'> | 10 | <div class='template-kind'> |
test/unit/profile_test.rb
@@ -1444,9 +1444,9 @@ class ProfileTest < ActiveSupport::TestCase | @@ -1444,9 +1444,9 @@ class ProfileTest < ActiveSupport::TestCase | ||
1444 | t2 = fast_create(Profile, :is_template => true) | 1444 | t2 = fast_create(Profile, :is_template => true) |
1445 | profile = fast_create(Profile) | 1445 | profile = fast_create(Profile) |
1446 | 1446 | ||
1447 | - assert_includes Profile.templates(Environment.default.id), t1 | ||
1448 | - assert_includes Profile.templates(Environment.default.id), t2 | ||
1449 | - assert_not_includes Profile.templates(Environment.default.id), profile | 1447 | + assert_includes Profile.templates(Environment.default), t1 |
1448 | + assert_includes Profile.templates(Environment.default), t2 | ||
1449 | + assert_not_includes Profile.templates(Environment.default), profile | ||
1450 | end | 1450 | end |
1451 | 1451 | ||
1452 | should 'provide URL to leave' do | 1452 | should 'provide URL to leave' do |