require_relative "base_model_test" class AplIdPrefixBuilderTest < BaseModelTest include AplIdPrefixBuilder context "get_apl_entity_prefix" do should "return default prefix for empty hash" do params = {} assert_equal Time.now().strftime('%Y%m%d'), get_apl_entity_prefix(params) end should "return default prefix for when type acronym is passed" do params = {:type_acronym => "ci"} assert_equal "ci" + Time.now().strftime('%Y%m%d'), get_apl_entity_prefix(params) end should "return default prefix for when type acronym and bu id is passed" do params = {:type_acronym => "ci", :bu_id => "test_bu"} assert_equal "test_bu" + "ci" + Time.now().strftime('%Y%m%d'), get_apl_entity_prefix(params) end should "return default prefix for when type acronym and bu id and date is passed" do time = Date.today - 3.day params = {:type_acronym => "ci", :bu_id => "test_bu", :time => time} assert_equal "test_bu" + "ci" + time.strftime('%Y%m%d'), get_apl_entity_prefix(params) end should "return default prefix for when type acronym and bu id and time and time format is passed" do time = Date.today - 3.day time_format = "%m%d" params = {:type_acronym => "ci", :bu_id => "test_bu", :time => time, :time_format => time_format} assert_equal "test_bu" + "ci" + time.strftime(time_format), get_apl_entity_prefix(params) end end end