2016-08-25 15:33:29 -05:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
describe ExtraLocalesController do
|
|
|
|
|
|
|
|
context 'show' do
|
|
|
|
|
2018-01-08 17:23:49 -06:00
|
|
|
it "caches for 24 hours if version is provided and it matches current hash" do
|
|
|
|
get :show, params: { bundle: 'admin', v: ExtraLocalesController.bundle_js_hash('admin') }
|
|
|
|
expect(response.headers["Cache-Control"]).to eq("max-age=86400, public, immutable")
|
|
|
|
end
|
|
|
|
|
|
|
|
it "does not cache at all if version is invalid" do
|
|
|
|
get :show, params: { bundle: 'admin', v: 'a' * 32 }
|
|
|
|
expect(response.headers["Cache-Control"]).not_to eq("max-age=86400, public, immutable")
|
|
|
|
end
|
|
|
|
|
2016-08-25 15:33:29 -05:00
|
|
|
it "needs a valid bundle" do
|
2017-08-30 23:06:56 -05:00
|
|
|
get :show, params: { bundle: 'made-up-bundle' }
|
2016-08-25 15:33:29 -05:00
|
|
|
expect(response).to_not be_success
|
|
|
|
expect(response.body).to be_blank
|
|
|
|
end
|
|
|
|
|
|
|
|
it "won't work with a weird parameter" do
|
2017-08-30 23:06:56 -05:00
|
|
|
get :show, params: { bundle: '-invalid..character!!' }
|
2016-08-25 15:33:29 -05:00
|
|
|
expect(response).to_not be_success
|
|
|
|
end
|
2016-09-28 15:26:36 -05:00
|
|
|
|
2017-02-24 04:31:21 -06:00
|
|
|
it "includes plugin translations" do
|
|
|
|
I18n.locale = :en
|
|
|
|
I18n.reload!
|
|
|
|
|
|
|
|
JsLocaleHelper.expects(:plugin_translations)
|
2017-07-27 20:20:09 -05:00
|
|
|
.with(I18n.locale.to_s)
|
|
|
|
.returns("admin_js" => {
|
2017-08-30 23:06:56 -05:00
|
|
|
"admin" => {
|
|
|
|
"site_settings" => {
|
|
|
|
"categories" => {
|
|
|
|
"github_badges" => "Github Badges"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}).at_least_once
|
|
|
|
|
|
|
|
get :show, params: { bundle: "admin" }
|
2016-09-28 15:26:36 -05:00
|
|
|
|
|
|
|
expect(response).to be_success
|
|
|
|
expect(response.body.include?("github_badges")).to eq(true)
|
|
|
|
end
|
|
|
|
|
2016-08-25 15:33:29 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|