cirandas.net

ref: master

plugins/section_block/test/functional/section_block_environment_design_controller_test.rb


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
require 'test_helper'

class EnvironmentDesignControllerTest < ActionController::TestCase

  def setup
    Environment.delete_all
    @environment = Environment.new(:name => 'testenv', :is_default => true)
    @environment.enabled_plugins = ['SectionBlockPlugin::SectionBlock']
    @environment.save!

    user = create_user('testinguser')
    @environment.add_admin(user.person)
    login_as(user.login)

    @block = create(SectionBlockPlugin::SectionBlock, :box => @environment.boxes.first)
  end

  should 'be able to edit SectionBlock' do
    get :edit, :id => @block.id
    assert_tag :tag => 'input', :attributes => { :id => 'block_title' }
  end

  should 'be able to save SectionBlock' do
    get :edit, :id => @block.id
    post :save, :id => @block.id, :block => {:title => 'Section' }
    @block.reload
    assert_equal 'Section', @block.title
  end

  should 'display section block' do
    get :index
    assert_tag :div, :attributes => { :id => "section-block-#{@block.id}" }
  end

  should 'display section name' do
    get :index
    assert_tag :span, :attributes => { :class => "section-block-name" }
  end

  should 'display section description' do
    get :index
    assert_tag :span, :attributes => { :class => "section-block-description" }
  end

end