From 1fdebc4b121236d2ae62caf99545b3d1e277875b Mon Sep 17 00:00:00 2001 From: Victor Costa Date: Thu, 9 Apr 2015 15:56:01 -0300 Subject: [PATCH] Hide embeded code in embeded mode --- test/functional/profile/pairwise_plugin_profile_controller_test.rb | 21 +++++++++++++++++++++ views/content_viewer/_result.html.erb | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/test/functional/profile/pairwise_plugin_profile_controller_test.rb b/test/functional/profile/pairwise_plugin_profile_controller_test.rb index 9784eaf..08dc061 100644 --- a/test/functional/profile/pairwise_plugin_profile_controller_test.rb +++ b/test/functional/profile/pairwise_plugin_profile_controller_test.rb @@ -220,6 +220,27 @@ class PairwisePluginProfileControllerTest < ActionController::TestCase assert_select "div[class='total_votes']", 1 end + should 'do not show embeded code when embeded' do + login_as(@user.user.login) + @question.expects(:get_choices).returns(PairwiseContentFixtures.choices_with_stats).at_least_once + PairwisePlugin::PairwiseContent.any_instance.expects(:question).returns(@question).at_least_once + PairwisePluginProfileController.any_instance.expects(:find_content).returns(@content).at_least_once + + xhr :get, :result, :profile => @profile.identifier, :id => @content.id, :question_id => @question.id, :embeded => true + + assert_select '.embeded_code_link', 0 + end + + should 'show embeded code when not embeded' do + login_as(@user.user.login) + @question.expects(:get_choices).returns(PairwiseContentFixtures.choices_with_stats).at_least_once + PairwisePlugin::PairwiseContent.any_instance.expects(:question).returns(@question).at_least_once + PairwisePluginProfileController.any_instance.expects(:find_content).returns(@content).at_least_once + + xhr :get, :result, :profile => @profile.identifier, :id => @content.id, :question_id => @question.id, :embeded => false + assert_select '.embeded_code_link', 1 + end + should 'suggest new idea' do login_as(@user.user.login) diff --git a/views/content_viewer/_result.html.erb b/views/content_viewer/_result.html.erb index 404ce3a..e1708f8 100644 --- a/views/content_viewer/_result.html.erb +++ b/views/content_viewer/_result.html.erb @@ -48,7 +48,7 @@ <% end %> - <% if @page.allow_edit?(user) %> + <% if !embeded && @page.allow_edit?(user) %>
<%= _("Show/Hide Embeded Code") %>