Merge pull request 'Store correct list of available manifest properties' (#3) from bugfix/empty_properties into master
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #3
This commit is contained in:
commit
59e4c9fb6a
@ -17,7 +17,8 @@ module Manifique
|
||||
[ :name, :short_name, :description, :icons,
|
||||
:theme_color, :background_color, :display,
|
||||
:start_url, :scope, :share_target ].map(&:to_s).each do |prop|
|
||||
self.send("#{prop}=", manifest[prop]) if manifest[prop]
|
||||
next unless manifest[prop]
|
||||
self.send("#{prop}=", manifest[prop])
|
||||
self.from_web_manifest.add(prop)
|
||||
end
|
||||
end
|
||||
|
1
spec/fixtures/mastodon-web-app-manifest.json
vendored
1
spec/fixtures/mastodon-web-app-manifest.json
vendored
@ -9,7 +9,6 @@
|
||||
"type": "image/png"
|
||||
}
|
||||
],
|
||||
"theme_color": "#282c37",
|
||||
"background_color": "#191b22",
|
||||
"display": "standalone",
|
||||
"start_url": "/web/timelines/home",
|
||||
|
@ -4,13 +4,13 @@ require "manifique/metadata"
|
||||
RSpec.describe Manifique::Metadata do
|
||||
|
||||
describe "#initialize" do
|
||||
it "sets the URL when given" do
|
||||
it "sets the URL" do
|
||||
metadata = Manifique::Metadata.new(url: "https://5apps.com")
|
||||
expect(metadata.url).to eq("https://5apps.com")
|
||||
end
|
||||
end
|
||||
|
||||
describe "#manifest=" do
|
||||
describe "#load_from_web_manifest" do
|
||||
let(:metadata) { Manifique::Metadata.new }
|
||||
let(:manifest) { JSON.parse(File.read(File.join(__dir__, "..", "fixtures", "mastodon-web-app-manifest.json"))) }
|
||||
|
||||
@ -22,7 +22,6 @@ RSpec.describe Manifique::Metadata do
|
||||
expect(metadata.name).to eq("kosmos.social")
|
||||
expect(metadata.short_name).to eq("kosmos.social")
|
||||
expect(metadata.description).to eq("A friendly place for tooting. Run by the Kosmos peeps.")
|
||||
expect(metadata.theme_color).to eq("#282c37")
|
||||
expect(metadata.background_color).to eq("#191b22")
|
||||
expect(metadata.display).to eq("standalone")
|
||||
expect(metadata.start_url).to eq("/web/timelines/home")
|
||||
@ -36,6 +35,14 @@ RSpec.describe Manifique::Metadata do
|
||||
}
|
||||
])
|
||||
end
|
||||
|
||||
it "stores the available property names in the from_web_manifest accessor" do
|
||||
expect((metadata.from_web_manifest & [
|
||||
"name", "short_name", "description", "icons", "background_color",
|
||||
"display", "start_url", "scope", "share_target"
|
||||
]).length).to eq(9)
|
||||
expect(metadata.from_web_manifest).not_to include("theme_color")
|
||||
end
|
||||
end
|
||||
|
||||
describe "#select_icon" do
|
||||
|
@ -189,7 +189,7 @@ RSpec.describe Manifique::WebClient do
|
||||
end
|
||||
|
||||
it "knows which properties were loaded from the web app manifest" do
|
||||
expect(subject.from_web_manifest.length).to eq(10)
|
||||
expect(subject.from_web_manifest.length).to eq(9)
|
||||
end
|
||||
|
||||
it "loads iOS icons from HTML" do
|
||||
|
Loading…
x
Reference in New Issue
Block a user