ref: master
plugins/variables/test/unit/profile_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 |
require 'test_helper' class ProfileTest < ActiveSupport::TestCase def setup @macro = VariablesPlugin::Profile.new @macro.context = mock() @profile = fast_create(Community) @macro.context.stubs(:profile).returns(@profile) end attr_reader :macro, :profile should 'have a configuration' do assert VariablesPlugin::Profile.configuration end should 'substitute the {profile} variable by the profile idenfifier' do html = 'the profile identifier is {profile}' content = macro.parse({}, html, profile) assert_equal "the profile identifier is #{profile.identifier}", content end should 'substitute the {name} variable by the profile name' do html = 'the profile name is {name}' content = macro.parse({}, html, profile) assert_equal "the profile name is #{profile.name}", content end should 'do not change the content if the variable is not supported' do html = 'the variable {unsupported} is not supported' content = macro.parse({}, html, profile) assert_equal html, content end should 'do nothing out of profile context' do macro.context.stubs(:profile).returns(nil) html = 'there is no {support} out of profile context' content = macro.parse({}, html, profile) assert_equal html, content end end |