-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #867 from openSUSE/product-localized-description
Fix localized description feature
- Loading branch information
Showing
7 changed files
with
138 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# frozen_string_literal: true | ||
|
||
# Copyright (c) [2023] SUSE LLC | ||
# | ||
# All Rights Reserved. | ||
# | ||
# This program is free software; you can redistribute it and/or modify it | ||
# under the terms of version 2 of the GNU General Public License as published | ||
# by the Free Software Foundation. | ||
# | ||
# This program is distributed in the hope that it will be useful, but WITHOUT | ||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
# more details. | ||
# | ||
# You should have received a copy of the GNU General Public License along | ||
# with this program; if not, contact SUSE LLC. | ||
# | ||
# To contact SUSE LLC about this file by physical or electronic mail, you may | ||
# find current contact information at www.suse.com. | ||
|
||
require_relative "../../test_helper" | ||
require "agama/software/product" | ||
|
||
describe Agama::Software::Product do | ||
subject { described_class.new("Test") } | ||
|
||
describe "#localized_description" do | ||
before do | ||
subject.description = "Original description" | ||
subject.translations = { | ||
"description" => { | ||
"cs" => "Czech translation", | ||
"es" => "Spanish translation" | ||
} | ||
} | ||
end | ||
|
||
it "returns untranslated description when the language is not set" do | ||
allow(ENV).to receive(:[]).with("LANG").and_return(nil) | ||
|
||
expect(subject.localized_description).to eq("Original description") | ||
end | ||
|
||
it "returns Czech translation if locale is \"cs_CZ.UTF-8\"" do | ||
allow(ENV).to receive(:[]).with("LANG").and_return("cs_CZ.UTF-8") | ||
|
||
expect(subject.localized_description).to eq("Czech translation") | ||
end | ||
|
||
it "returns Czech translation if locale is \"cs\"" do | ||
allow(ENV).to receive(:[]).with("LANG").and_return("cs") | ||
|
||
expect(subject.localized_description).to eq("Czech translation") | ||
end | ||
|
||
it "return untranslated description when translation is not available" do | ||
allow(ENV).to receive(:[]).with("LANG").and_return("cs_CZ.UTF-8") | ||
subject.translations = {} | ||
|
||
expect(subject.localized_description).to eq("Original description") | ||
end | ||
end | ||
end |