3 class AppVersionTest < ActiveSupport::TestCase
5 setup do AppVersion.forget end
7 teardown do AppVersion.forget end
9 test 'invoke git processes only on first call' do
10 AppVersion.expects(:git).
11 with("status", "--porcelain").once.
12 yields " M services/api/README\n"
13 AppVersion.expects(:git).
14 with("log", "-n1", "--format=%H").once.
15 yields "da39a3ee5e6b4b0d3255bfef95601890afd80709\n"
19 assert_equal 'da39a3ee-modified', v
23 test 'override with configuration "foobar"' do
24 Rails.configuration.source_version = 'foobar'
25 assert_equal 'foobar', AppVersion.hash
28 test 'override with configuration false' do
29 Rails.configuration.source_version = false
30 assert_not_equal 'foobar', AppVersion.hash
33 test 'override with file' do
34 path = Rails.root.join 'git-commit.version'
35 assert(!File.exist?(path),
36 "Packaged version file found in source tree: #{path}")
38 File.open(path, 'w') do |f|
39 f.write "0.1.abc123\n"
41 assert_equal "0.1.abc123", AppVersion.hash