summaryrefslogtreecommitdiffstats
path: root/vendor/plugins/engines/test/unit/assets_test.rb
blob: 3332c533eecde1de5311c431a211ec83e7be522d (plain)
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
49
50
51
52
require File.dirname(__FILE__) + '/../test_helper'

class AssetsTest < Test::Unit::TestCase  
  def setup
    Engines::Assets.mirror_files_for Engines.plugins[:test_assets]
  end
  
  def teardown
    FileUtils.rm_r(Engines.public_directory) if File.exist?(Engines.public_directory)
  end
  
  def test_engines_has_created_base_public_file
    assert File.exist?(Engines.public_directory)
  end
  
  def test_engines_has_created_README_in_public_directory
    assert File.exist?(File.join(Engines.public_directory, 'README'))
  end
  
  def test_public_files_have_been_copied_from_test_assets_plugin
    assert File.exist?(File.join(Engines.public_directory, 'test_assets'))
    assert File.exist?(File.join(Engines.public_directory, 'test_assets', 'file.txt'))
    assert File.exist?(File.join(Engines.public_directory, 'test_assets', 'subfolder'))
    assert File.exist?(File.join(Engines.public_directory, 'test_assets', 'subfolder', 'file_in_subfolder.txt'))
  end
  
  def test_engines_has_not_created_duplicated_file_structure
    assert !File.exists?(File.join(Engines.public_directory, "test_assets", RAILS_ROOT))
  end
  
  def test_public_files_have_been_copied_from_test_assets_with_assets_dir_plugin
    Engines::Assets.mirror_files_for Engines.plugins[:test_assets_with_assets_directory]

    assert File.exist?(File.join(Engines.public_directory, 'test_assets_with_assets_directory'))
    assert File.exist?(File.join(Engines.public_directory, 'test_assets_with_assets_directory', 'file.txt'))
    assert File.exist?(File.join(Engines.public_directory, 'test_assets_with_assets_directory', 'subfolder'))
    assert File.exist?(File.join(Engines.public_directory, 'test_assets_with_assets_directory', 'subfolder', 'file_in_subfolder.txt'))
  end
  
  def test_public_files_have_been_copied_from_test_assets_with_no_subdirectory_plugin
    Engines::Assets.mirror_files_for Engines.plugins[:test_assets_with_no_subdirectory]

    assert File.exist?(File.join(Engines.public_directory, 'test_assets_with_no_subdirectory'))
    assert File.exist?(File.join(Engines.public_directory, 'test_assets_with_no_subdirectory', 'file.txt'))    
  end
  
  def test_public_files_have_NOT_been_copied_from_plugins_without_public_or_asset_directories
    Engines::Assets.mirror_files_for Engines.plugins[:alpha_plugin]
    
    assert !File.exist?(File.join(Engines.public_directory, 'alpha_plugin'))
  end
end