diff --git a/app/controllers/embed_controller.rb b/app/controllers/embed_controller.rb index 60755e9..01861b3 100644 --- a/app/controllers/embed_controller.rb +++ b/app/controllers/embed_controller.rb @@ -3,12 +3,11 @@ class EmbedController < ApplicationController def block @block = Block.find(params[:id]) - @source = params[:source] if !@block.embedable? || !@block.visible? - render :template => 'shared/embed_unavailable.rhtml', :status => 403 + render 'unavailable.rhtml', :status => 403 end rescue ActiveRecord::RecordNotFound - render :template => 'shared/embed_not_found.rhtml', :status => 404 + render 'not_found.rhtml', :status => 404 end end diff --git a/app/views/embed/not_found.rhtml b/app/views/embed/not_found.rhtml new file mode 100644 index 0000000..49785b8 --- /dev/null +++ b/app/views/embed/not_found.rhtml @@ -0,0 +1,6 @@ +
+

+ <%= _('You may have clicked an expired link or mistyped the address.') %> + <%= _('If you clicked a link that was in another site, or was given to you by someone else, it would be nice if you tell them that their link is not valid anymore.') %> +

+
diff --git a/app/views/embed/unavailable.rhtml b/app/views/embed/unavailable.rhtml new file mode 100644 index 0000000..6fb5d5e --- /dev/null +++ b/app/views/embed/unavailable.rhtml @@ -0,0 +1,3 @@ +
+

<%= _('Embed unavailable.') %>

+
diff --git a/app/views/shared/embed_not_found.rhtml b/app/views/shared/embed_not_found.rhtml deleted file mode 100644 index 49785b8..0000000 --- a/app/views/shared/embed_not_found.rhtml +++ /dev/null @@ -1,6 +0,0 @@ -
-

- <%= _('You may have clicked an expired link or mistyped the address.') %> - <%= _('If you clicked a link that was in another site, or was given to you by someone else, it would be nice if you tell them that their link is not valid anymore.') %> -

-
diff --git a/app/views/shared/embed_unavailable.rhtml b/app/views/shared/embed_unavailable.rhtml deleted file mode 100644 index 78503b7..0000000 --- a/app/views/shared/embed_unavailable.rhtml +++ /dev/null @@ -1,3 +0,0 @@ -
-

<%= _('Embed unavailable.') %>

-
diff --git a/test/functional/embed_controller.rb b/test/functional/embed_controller.rb deleted file mode 100644 index 6b8e7f8..0000000 --- a/test/functional/embed_controller.rb +++ /dev/null @@ -1,31 +0,0 @@ -require File.dirname(__FILE__) + '/../test_helper' - -class EmbedControllerTest < ActionController::TestCase - - def setup - login_as(create_admin_user(Environment.default)) - @block = LoginBlock.create! - @environment = Environment.default - @environment.boxes.create! - @environment.boxes.first.blocks << @block - end - - should 'be able to get embed block' do - get :index, :id => @block.id - assert_tag :tag => 'div', :attributes => { :id => "block-#{@block.id}" } - end - - should 'display error message when not found block' do - Block.delete_all - get :index, :id => 1 - assert_tag :tag => 'div', :attributes => { :id => "not-found" } - end - - should 'display error message when block is not visible/public' do - @block.display = 'never' - @block.save - get :index, :id => @block.id - assert_tag :tag => 'div', :attributes => { :id => "not-found" } - end - -end diff --git a/test/functional/embed_controller_test.rb b/test/functional/embed_controller_test.rb new file mode 100644 index 0000000..8cc7cff --- /dev/null +++ b/test/functional/embed_controller_test.rb @@ -0,0 +1,39 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class EmbedControllerTest < ActionController::TestCase + + def setup + login_as(create_admin_user(Environment.default)) + @block = LoginBlock.create! + @block.class.any_instance.stubs(:embedable?).returns(true) + @environment = Environment.default + @environment.boxes.create! + @environment.boxes.first.blocks << @block + end + + should 'be able to get embed block' do + get :block, :id => @block.id + assert_tag :tag => 'div', :attributes => { :id => "block-#{@block.id}" } + end + + should 'display error message when not found block' do + Block.delete_all + get :block, :id => 1 + assert_tag :tag => 'div', :attributes => { :id => "not-found" } + end + + should 'display error message when block is not visible/public' do + @block.display = 'never' + assert @block.save + get :block, :id => @block.id + assert_tag :tag => 'div', :attributes => { :id => "unavailable" } + end + + should 'display error message when block is not embedable' do + @block.class.any_instance.stubs(:embedable?).returns(false) + get :block, :id => @block.id + assert_tag :tag => 'div', :attributes => { :id => "unavailable" } + end + + +end -- libgit2 0.21.2