1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-23 15:19:38 +02:00

Fix auto upgrade logic (#758)

This commit is contained in:
Zach Gollwitzer 2024-05-17 17:25:15 -04:00 committed by GitHub
parent ddf26cd5e5
commit 0d0f766ca1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 61 additions and 23 deletions

View file

@ -0,0 +1,36 @@
require "test_helper"
class UpgradeTest < ActiveSupport::TestCase
setup do
data = {
commit_sha: "latestcommit",
version: Semver.new("0.1.0-alpha.2")
}
@commit_upgrade = Upgrader::Upgrade.new "commit", data
@release_upgrade = Upgrader::Upgrade.new "release", data
end
test "available if latest commit and app not upgraded" do
Maybe.stubs(:version).returns(@commit_upgrade.version)
Maybe.stubs(:commit_sha).returns("outdatedcommitsha")
assert @commit_upgrade.available?
assert_not @release_upgrade.available?
end
test "available if latest release and app not upgraded" do
Maybe.stubs(:version).returns(Semver.new("0.1.0-alpha.1"))
Maybe.stubs(:commit_sha).returns("outdatedcommitsha")
assert @commit_upgrade.available?
assert @release_upgrade.available?
end
test "not available if app commit greater or equal to" do
Maybe.stubs(:version).returns(@commit_upgrade.version)
Maybe.stubs(:commit_sha).returns(@commit_upgrade.commit_sha)
assert_not @commit_upgrade.available?
end
end