diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 99812c9..39493cd 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -313,15 +313,9 @@ module ApplicationHelper
raise ArgumentError, 'No partial for object. Is there a partial for any class in the inheritance hierarchy?'
end
- def view_for_profile_actions(klass)
- raise ArgumentError, 'No profile actions view for this class.' if klass.nil?
-
- name = klass.name.underscore
- VIEW_EXTENSIONS.each do |ext|
- return "blocks/profile_info_actions/"+name+ext if File.exists?(File.join(RAILS_ROOT, 'app', 'views', 'blocks', 'profile_info_actions', name+ext))
- end
-
- view_for_profile_actions(klass.superclass)
+ def render_profile_actions klass
+ name = klass.to_s.underscore
+ render "blocks/profile_info_actions/#{name}" rescue render_profile_actions klass.superclass
end
def user
diff --git a/app/views/blocks/my_network.rhtml b/app/views/blocks/my_network.rhtml
index 14d39a3..06f8a70 100644
--- a/app/views/blocks/my_network.rhtml
+++ b/app/views/blocks/my_network.rhtml
@@ -11,5 +11,5 @@
- <%= render :file => 'blocks/profile_info_actions/' + owner.class.name.underscore %>
+ <%= render_profile_actions owner.class.name.underscore %>
diff --git a/app/views/blocks/profile_image.rhtml b/app/views/blocks/profile_image.rhtml
index 6e27279..0b76327 100644
--- a/app/views/blocks/profile_image.rhtml
+++ b/app/views/blocks/profile_image.rhtml
@@ -23,6 +23,6 @@
<% end %>
- <%= render :file => view_for_profile_actions(block.owner.class) %>
+ <%= render_profile_actions block.owner.class %>
diff --git a/app/views/blocks/profile_info.rhtml b/app/views/blocks/profile_info.rhtml
index d983432..6cc327e 100644
--- a/app/views/blocks/profile_info.rhtml
+++ b/app/views/blocks/profile_info.rhtml
@@ -40,7 +40,7 @@
<% end %>
- <%= render :file => view_for_profile_actions(block.owner.class) %>
+ <%= render_profile_actions block.owner.class %>
diff --git a/app/views/blocks/profile_info_actions/_community.html.erb b/app/views/blocks/profile_info_actions/_community.html.erb
new file mode 100644
index 0000000..61392ab
--- /dev/null
+++ b/app/views/blocks/profile_info_actions/_community.html.erb
@@ -0,0 +1,20 @@
+
+ -
+ <%= render "blocks/profile_info_actions/join_leave_community" %>
+
+ <% if logged_in? %>
+ <% if profile.enable_contact? %>
+ -
+ <%= link_to content_tag('span', _('Send an e-mail')),
+ { :profile => profile.identifier,
+ :controller => 'contact',
+ :action => 'new' },
+ {:class => 'button with-text icon-menu-mail', :title => _('Send an e-mail to the administrators')} %>
+
+ <% end %>
+
+ - <%= report_abuse(profile, :button) %>
+
+ <%= render_environment_features(:profile_actions) %>
+ <% end %>
+
diff --git a/app/views/blocks/profile_info_actions/_enterprise.html.erb b/app/views/blocks/profile_info_actions/_enterprise.html.erb
new file mode 100644
index 0000000..134a67e
--- /dev/null
+++ b/app/views/blocks/profile_info_actions/_enterprise.html.erb
@@ -0,0 +1,12 @@
+
+ <%if logged_in? %>
+ <%if !user.favorite_enterprises.include?(profile) %>
+ - <%= link_to content_tag('span', _('Add as favorite')), { :profile => user.identifier, :controller => 'favorite_enterprises', :action => 'add', :id => profile.id }, :class => 'button with-text icon-add', :title => __('Add enterprise as favorite') %>
+ <% end %>
+ <% end %>
+ <% if profile.enable_contact? %>
+ - <%= link_to content_tag('span', _('Send an e-mail')), {:profile => profile.identifier, :controller => 'contact', :action => 'new'}, {:id => 'enterprise-contact-button', :class => 'button with-text icon-menu-mail'} %>
+ <% end %>
+
+ - <%= report_abuse(profile, :button) %>
+
diff --git a/app/views/blocks/profile_info_actions/_organization.html.erb b/app/views/blocks/profile_info_actions/_organization.html.erb
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/app/views/blocks/profile_info_actions/_organization.html.erb
diff --git a/app/views/blocks/profile_info_actions/_person.html.erb b/app/views/blocks/profile_info_actions/_person.html.erb
new file mode 100644
index 0000000..5b430c1
--- /dev/null
+++ b/app/views/blocks/profile_info_actions/_person.html.erb
@@ -0,0 +1,16 @@
+
+ <%if logged_in? && (user != profile) %>
+
+ <% if !user.already_request_friendship?(profile) and !user.is_a_friend?(profile) %>
+ -
+ <%= button(:add, content_tag('span', __('Add friend')), profile.add_url, :class => 'add-friend', :title => _("Add friend"), :style => 'position: relative;') %>
+
+ <% end %>
+
+ <% if user.is_a_friend?(profile) && profile.enable_contact? %>
+ - <%= link_to content_tag('span', _('Send an e-mail')), {:profile => profile.identifier, :controller => 'contact', :action => 'new'}, :class => 'button with-text icon-menu-mail' %>
+ <% end %>
+
+ - <%= report_abuse(profile, :button) %>
+ <% end %>
+
diff --git a/app/views/blocks/profile_info_actions/community.rhtml b/app/views/blocks/profile_info_actions/community.rhtml
deleted file mode 100644
index d92bf90..0000000
--- a/app/views/blocks/profile_info_actions/community.rhtml
+++ /dev/null
@@ -1,20 +0,0 @@
-
- -
- <%= render "blocks/profile_info_actions/join_leave_community" %>
-
- <% if logged_in? %>
- <% if profile.enable_contact? %>
- -
- <%= link_to content_tag('span', _('Send an e-mail')),
- { :profile => profile.identifier,
- :controller => 'contact',
- :action => 'new' },
- {:class => 'button with-text icon-menu-mail', :title => _('Send an e-mail to the administrators')} %>
-
- <% end %>
-
- - <%= report_abuse(profile, :button) %>
-
- <%= render_environment_features(:profile_actions) %>
- <% end %>
-
\ No newline at end of file
diff --git a/app/views/blocks/profile_info_actions/enterprise.rhtml b/app/views/blocks/profile_info_actions/enterprise.rhtml
deleted file mode 100644
index 134a67e..0000000
--- a/app/views/blocks/profile_info_actions/enterprise.rhtml
+++ /dev/null
@@ -1,12 +0,0 @@
-
- <%if logged_in? %>
- <%if !user.favorite_enterprises.include?(profile) %>
- - <%= link_to content_tag('span', _('Add as favorite')), { :profile => user.identifier, :controller => 'favorite_enterprises', :action => 'add', :id => profile.id }, :class => 'button with-text icon-add', :title => __('Add enterprise as favorite') %>
- <% end %>
- <% end %>
- <% if profile.enable_contact? %>
- - <%= link_to content_tag('span', _('Send an e-mail')), {:profile => profile.identifier, :controller => 'contact', :action => 'new'}, {:id => 'enterprise-contact-button', :class => 'button with-text icon-menu-mail'} %>
- <% end %>
-
- - <%= report_abuse(profile, :button) %>
-
diff --git a/app/views/blocks/profile_info_actions/organization.rhtml b/app/views/blocks/profile_info_actions/organization.rhtml
deleted file mode 100644
index e69de29..0000000
--- a/app/views/blocks/profile_info_actions/organization.rhtml
+++ /dev/null
diff --git a/app/views/blocks/profile_info_actions/person.rhtml b/app/views/blocks/profile_info_actions/person.rhtml
deleted file mode 100644
index 5b430c1..0000000
--- a/app/views/blocks/profile_info_actions/person.rhtml
+++ /dev/null
@@ -1,16 +0,0 @@
-
- <%if logged_in? && (user != profile) %>
-
- <% if !user.already_request_friendship?(profile) and !user.is_a_friend?(profile) %>
- -
- <%= button(:add, content_tag('span', __('Add friend')), profile.add_url, :class => 'add-friend', :title => _("Add friend"), :style => 'position: relative;') %>
-
- <% end %>
-
- <% if user.is_a_friend?(profile) && profile.enable_contact? %>
- - <%= link_to content_tag('span', _('Send an e-mail')), {:profile => profile.identifier, :controller => 'contact', :action => 'new'}, :class => 'button with-text icon-menu-mail' %>
- <% end %>
-
- - <%= report_abuse(profile, :button) %>
- <% end %>
-
diff --git a/test/unit/application_helper_test.rb b/test/unit/application_helper_test.rb
index 7106acd..7f72a43 100644
--- a/test/unit/application_helper_test.rb
+++ b/test/unit/application_helper_test.rb
@@ -53,15 +53,6 @@ class ApplicationHelperTest < ActiveSupport::TestCase
assert_equal 'test/application_helper_test/school/project', partial_for_class(School::Project)
end
- should 'look for superclasses on view_for_profile actions' do
- File.expects(:exists?).with("#{RAILS_ROOT}/app/views/blocks/profile_info_actions/float.rhtml").returns(false)
- File.expects(:exists?).with("#{RAILS_ROOT}/app/views/blocks/profile_info_actions/float.html.erb").returns(false)
- File.expects(:exists?).with("#{RAILS_ROOT}/app/views/blocks/profile_info_actions/numeric.rhtml").returns(false)
- File.expects(:exists?).with("#{RAILS_ROOT}/app/views/blocks/profile_info_actions/numeric.html.erb").returns(true)
-
- assert_equal 'blocks/profile_info_actions/numeric.html.erb', view_for_profile_actions(Float)
- end
-
should 'give error when there is no partial for class' do
assert_raises ArgumentError do
partial_for_class(nil)
--
libgit2 0.21.2