Commit fe8dbbb43f893c21c3267d21be88d9ea0eacfc2d
1 parent
b47d43ac
Exists in
master
and in
22 other branches
Test files should ends with "_test.rb"
also, moving views from app/views/shared to app/views/embed (ActionItem3031)
Showing
7 changed files
with
50 additions
and
43 deletions
Show diff stats
app/controllers/embed_controller.rb
... | ... | @@ -3,12 +3,11 @@ class EmbedController < ApplicationController |
3 | 3 | |
4 | 4 | def block |
5 | 5 | @block = Block.find(params[:id]) |
6 | - @source = params[:source] | |
7 | 6 | if !@block.embedable? || !@block.visible? |
8 | - render :template => 'shared/embed_unavailable.rhtml', :status => 403 | |
7 | + render 'unavailable.rhtml', :status => 403 | |
9 | 8 | end |
10 | 9 | rescue ActiveRecord::RecordNotFound |
11 | - render :template => 'shared/embed_not_found.rhtml', :status => 404 | |
10 | + render 'not_found.rhtml', :status => 404 | |
12 | 11 | end |
13 | 12 | |
14 | 13 | end | ... | ... |
... | ... | @@ -0,0 +1,6 @@ |
1 | +<div id='not-found'> | |
2 | + <p> | |
3 | + <%= _('You may have clicked an expired link or mistyped the address.') %> | |
4 | + <%= _('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.') %> | |
5 | + </p> | |
6 | +</div> | ... | ... |
app/views/shared/embed_not_found.rhtml
... | ... | @@ -1,6 +0,0 @@ |
1 | -<div id='not-found'> | |
2 | - <p> | |
3 | - <%= _('You may have clicked an expired link or mistyped the address.') %> | |
4 | - <%= _('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.') %> | |
5 | - </p> | |
6 | -</div> |
app/views/shared/embed_unavailable.rhtml
test/functional/embed_controller.rb
... | ... | @@ -1,31 +0,0 @@ |
1 | -require File.dirname(__FILE__) + '/../test_helper' | |
2 | - | |
3 | -class EmbedControllerTest < ActionController::TestCase | |
4 | - | |
5 | - def setup | |
6 | - login_as(create_admin_user(Environment.default)) | |
7 | - @block = LoginBlock.create! | |
8 | - @environment = Environment.default | |
9 | - @environment.boxes.create! | |
10 | - @environment.boxes.first.blocks << @block | |
11 | - end | |
12 | - | |
13 | - should 'be able to get embed block' do | |
14 | - get :index, :id => @block.id | |
15 | - assert_tag :tag => 'div', :attributes => { :id => "block-#{@block.id}" } | |
16 | - end | |
17 | - | |
18 | - should 'display error message when not found block' do | |
19 | - Block.delete_all | |
20 | - get :index, :id => 1 | |
21 | - assert_tag :tag => 'div', :attributes => { :id => "not-found" } | |
22 | - end | |
23 | - | |
24 | - should 'display error message when block is not visible/public' do | |
25 | - @block.display = 'never' | |
26 | - @block.save | |
27 | - get :index, :id => @block.id | |
28 | - assert_tag :tag => 'div', :attributes => { :id => "not-found" } | |
29 | - end | |
30 | - | |
31 | -end |
... | ... | @@ -0,0 +1,39 @@ |
1 | +require File.dirname(__FILE__) + '/../test_helper' | |
2 | + | |
3 | +class EmbedControllerTest < ActionController::TestCase | |
4 | + | |
5 | + def setup | |
6 | + login_as(create_admin_user(Environment.default)) | |
7 | + @block = LoginBlock.create! | |
8 | + @block.class.any_instance.stubs(:embedable?).returns(true) | |
9 | + @environment = Environment.default | |
10 | + @environment.boxes.create! | |
11 | + @environment.boxes.first.blocks << @block | |
12 | + end | |
13 | + | |
14 | + should 'be able to get embed block' do | |
15 | + get :block, :id => @block.id | |
16 | + assert_tag :tag => 'div', :attributes => { :id => "block-#{@block.id}" } | |
17 | + end | |
18 | + | |
19 | + should 'display error message when not found block' do | |
20 | + Block.delete_all | |
21 | + get :block, :id => 1 | |
22 | + assert_tag :tag => 'div', :attributes => { :id => "not-found" } | |
23 | + end | |
24 | + | |
25 | + should 'display error message when block is not visible/public' do | |
26 | + @block.display = 'never' | |
27 | + assert @block.save | |
28 | + get :block, :id => @block.id | |
29 | + assert_tag :tag => 'div', :attributes => { :id => "unavailable" } | |
30 | + end | |
31 | + | |
32 | + should 'display error message when block is not embedable' do | |
33 | + @block.class.any_instance.stubs(:embedable?).returns(false) | |
34 | + get :block, :id => @block.id | |
35 | + assert_tag :tag => 'div', :attributes => { :id => "unavailable" } | |
36 | + end | |
37 | + | |
38 | + | |
39 | +end | ... | ... |