Skip to content

Commit

Permalink
[api] package#self.valid_name? returns true/false
Browse files Browse the repository at this point in the history
Make package#self.valid_name? return only tru or false as it used to
return 0 too.
  • Loading branch information
Ana06 committed Jan 17, 2017
1 parent 3fa9c6b commit 194dae6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/api/app/models/package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -998,7 +998,7 @@ def self.valid_name?(name)
if name =~ %r{^[_\.]} && !%w(_product _pattern _project _patchinfo).include?(name)
return false
end
name =~ /\A\w[-+\w\.]*\z/
name =~ /\A\w[-+\w\.]*\z/ ? true : false
end

def valid_name
Expand Down
12 changes: 6 additions & 6 deletions src/api/spec/models/package_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@
guard string !~ /^(_product|_product:\w|_patchinfo|_patchinfo:\w|_pattern|_project)/
string
}.check { |string|
expect(Package.valid_name?(string)).to be_in([nil, false])
expect(Package.valid_name?(string)).to be(false)
}
end

Expand All @@ -234,7 +234,7 @@
guard string != '0'
string
}.check { |string|
expect(Package.valid_name?(string)).to eq(0)
expect(Package.valid_name?(string)).to be(true)
}
end

Expand All @@ -258,10 +258,10 @@
}
end

it{ expect(Package.valid_name?('_product')).to eq(0) }
it{ expect(Package.valid_name?('_pattern')).to eq(0) }
it{ expect(Package.valid_name?('_project')).to eq(0) }
it{ expect(Package.valid_name?('_patchinfo')).to eq(0) }
it{ expect(Package.valid_name?('_product')).to be(true) }
it{ expect(Package.valid_name?('_pattern')).to be(true) }
it{ expect(Package.valid_name?('_project')).to be(true) }
it{ expect(Package.valid_name?('_patchinfo')).to be(true) }
end
end
end

0 comments on commit 194dae6

Please sign in to comment.