Skip to content

Commit

Permalink
[android] version_code must be an int
Browse files Browse the repository at this point in the history
  • Loading branch information
goya committed Sep 24, 2016
1 parent dd176c4 commit adebb49
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
5 changes: 3 additions & 2 deletions lib/confetti/templates/android_manifest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ def version
def version_code
config_version_code = @config.preference("android-versionCode", :android) ||
@config.android_versioncode ||
@config.version_code
@config.version_code ||
"1"

config_version_code.nil? ? '1' : config_version_code.to_s
(config_version_code =~ /\A\d+\Z/) ? config_version_code.to_s : "1"
end

def app_orientation
Expand Down
2 changes: 1 addition & 1 deletion lib/confetti/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Confetti
VERSION = "0.16.15"
VERSION = "0.16.16"
end
33 changes: 33 additions & 0 deletions spec/templates/android_manifest_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,39 @@
end
end

describe "#version_code" do
before do
@config = Confetti::Config.new
@template = @template_class.new(@config)
end

it "should default to 1" do
@template.version_code.should == "1"
end

describe "when set" do
before do
@v_pref = Confetti::Config::Preference.new "android-versionCode"
@config.preference_set << @v_pref
end

it "should return that number" do
@v_pref.value = "12"
@template.version_code.should == '12'
end

it "should be 1 if not an integer" do
@v_pref.value = "12.0"
@template.version_code.should == "1"
end

it "should be 1 if not a number" do
@v_pref.value = "twelve"
@template.version_code.should == "1"
end
end
end

describe "#max_sdk_version_attribute" do
before do
@config = Confetti::Config.new
Expand Down

0 comments on commit adebb49

Please sign in to comment.