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' do
24 Rails.configuration.source_version = 'foobar'
25 assert_equal 'foobar', AppVersion.hash
26 Rails.configuration.source_version = false
27 assert_not_equal 'foobar', AppVersion.hash
30 test 'override with file' do
31 path = Rails.root.join 'git-commit.version'
32 assert(!File.exists?(path),
33 "Packaged version file found in source tree: #{path}")
35 File.open(path, 'w') do |f|
36 f.write "0.1.abc123\n"
38 assert_equal "0.1.abc123", AppVersion.hash