FIX: Support version in new feature payload (#11841)
Followup to 4f01ca87e3
This commit is contained in:
parent
363dca5ddc
commit
568bad75c1
|
@ -131,6 +131,10 @@ module DiscourseUpdates
|
|||
entries.select! { |item| Time.zone.parse(item["created_at"]) > last_seen }
|
||||
end
|
||||
|
||||
entries.select! do |item|
|
||||
item["discourse_version"].nil? || Discourse.has_needed_version?(Discourse::VERSION::STRING, item["discourse_version"]) rescue nil
|
||||
end
|
||||
|
||||
entries.sort { |item| Time.zone.parse(item["created_at"]) }
|
||||
end
|
||||
|
||||
|
|
|
@ -211,5 +211,25 @@ describe DiscourseUpdates do
|
|||
expect(result.length).to eq(1)
|
||||
expect(result[0]["title"]).to eq("Brand New Item")
|
||||
end
|
||||
|
||||
it 'correctly shows features by Discourse version' do
|
||||
features_with_versions = [
|
||||
{ "emoji" => "🤾", "title" => "Bells", "created_at" => 40.minutes.ago },
|
||||
{ "emoji" => "🙈", "title" => "Whistles", "created_at" => 20.minutes.ago, discourse_version: "2.6.0.beta1" },
|
||||
{ "emoji" => "🙈", "title" => "Confetti", "created_at" => 15.minutes.ago, discourse_version: "2.7.0.beta2" },
|
||||
{ "emoji" => "🤾", "title" => "Not shown yet", "created_at" => 10.minutes.ago, discourse_version: "2.7.0.beta5" },
|
||||
{ "emoji" => "🤾", "title" => "Not shown yet (beta < stable)", "created_at" => 10.minutes.ago, discourse_version: "2.7.0" },
|
||||
{ "emoji" => "🤾", "title" => "Ignore invalid version", "created_at" => 10.minutes.ago, discourse_version: "invalid-version" },
|
||||
]
|
||||
|
||||
Discourse.redis.set('new_features', MultiJson.dump(features_with_versions))
|
||||
DiscourseUpdates.stubs(:last_installed_version).returns("2.7.0.beta2")
|
||||
result = DiscourseUpdates.unseen_new_features(admin.id)
|
||||
|
||||
expect(result.length).to eq(3)
|
||||
expect(result[0]["title"]).to eq("Confetti")
|
||||
expect(result[1]["title"]).to eq("Whistles")
|
||||
expect(result[2]["title"]).to eq("Bells")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue