ref: master
plugins/context_content/test/functional/profile_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 46 47 48 |
require 'test_helper' class ProfileDesignControllerTest < ActionController::TestCase def setup Environment.delete_all @environment = Environment.create(:name => 'testenv', :is_default => true) @environment.enabled_plugins = ['ContextContentPlugin'] @environment.save! @profile = fast_create(Community, :environment_id => @environment.id) @page = fast_create(Folder, :profile_id => @profile.id) box = Box.create!(:owner => @profile) @block = ContextContentPlugin::ContextContentBlock.new(:box_id => box.id) @block.types = ['TextArticle'] @block.limit = 1 @block.save! user = create_user('testinguser') @profile.add_admin(user.person) login_as(user.login) end should 'be able to edit context content block' do get :edit, :id => @block.id, :profile => @profile.identifier assert_tag :tag => 'input', :attributes => { :id => 'block_title' } assert_tag :tag => 'input', :attributes => { :id => 'block_show_image' } assert_tag :tag => 'input', :attributes => { :id => 'block_show_name' } assert_tag :tag => 'input', :attributes => { :id => 'block_use_parent_title' } assert_tag :tag => 'input', :attributes => { :id => 'block_show_parent_content' } assert_tag :tag => 'input', :attributes => { :name => 'block[types][]' } end should 'be able to save TrackListBlock' do @block.show_image = false @block.show_name = false @block.show_parent_content = false @block.save! get :edit, :id => @block.id, :profile => @profile.identifier post :save, :id => @block.id, :block => {:title => 'context', :show_image => '0', :show_name => '0', :show_parent_content => '0', :types => ['TextArticle', '', nil, 'Folder'] }, :profile => @profile.identifier @block.reload assert_equal 'context', @block.title refute @block.show_image && !@block.show_name && !@block.show_parent_content assert_equal ['TextArticle', 'Folder'], @block.types end end |