8784: Fix test for latest firefox.
[arvados.git] / services / api / test / unit / app_version_test.rb
1 require 'test_helper'
2
3 class AppVersionTest < ActiveSupport::TestCase
4
5   setup do AppVersion.forget end
6
7   teardown do AppVersion.forget end
8
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"
16
17     (0..4).each do
18       v = AppVersion.hash
19       assert_equal 'da39a3ee-modified', v
20     end
21   end
22
23   test 'override with configuration "foobar"' do
24     Rails.configuration.source_version = 'foobar'
25     assert_equal 'foobar', AppVersion.hash
26   end
27
28   test 'override with configuration false' do
29     Rails.configuration.source_version = false
30     assert_not_equal 'foobar', AppVersion.hash
31   end
32
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}")
37     begin
38       File.open(path, 'w') do |f|
39         f.write "0.1.abc123\n"
40       end
41       assert_equal "0.1.abc123", AppVersion.hash
42     ensure
43       File.unlink path
44     end
45   end
46 end