Skip to content

Commit

Permalink
update specs for locale detection
Browse files Browse the repository at this point in the history
  • Loading branch information
sethherr committed Dec 10, 2023
1 parent 1c2e2d5 commit 174e9f2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
6 changes: 4 additions & 2 deletions spec/helpers/organized_helper_spec.rb
Expand Up @@ -63,12 +63,14 @@
end
it "renders text-warning" do
expect(status_display("stolen")).to eq "<span class=\"text-warning\">stolen</span>"
expect(status_display("uncertified_by_trusted_org")).to eq "<span class=\"text-warning\">uncertified by trusted org</span>"
end
context "retrieved" do
it "is blue" do
context "text-info" do
it "is expected" do
expect(status_display("retrieved_by_owner")).to eq "<span class=\"text-info\">retrieved by owner</span>"
expect(status_display("Retrieved")).to eq "<span class=\"text-info\">Retrieved</span>"
expect(status_display("resolved_otherwise")).to eq "<span class=\"text-info\">resolved</span>"
expect(status_display("certified_by_trusted_org")).to eq "<span class=\"text-info\">certified by trusted org</span>"
end
end
context "removed_from_bike_index, trashed or Removed from Bike Index" do
Expand Down
28 changes: 14 additions & 14 deletions spec/requests/locale_detection_request_spec.rb
Expand Up @@ -36,9 +36,9 @@
get "/"
expect(response.body).to match(/sykkelregistrering/i)

current_user.update(preferred_language: :es)
get "/"
expect(response.body).to match(/registro de bicicletas/i)
# current_user.update(preferred_language: :es)
# get "/"
# expect(response.body).to match(/registro de bicicletas/i)
end
end

Expand All @@ -50,8 +50,8 @@
expect(response.body).to match(/fietsregistratie/i)
get "/", params: {locale: :nb}
expect(response.body).to match(/sykkelregistrering/i)
get "/", params: {locale: :nb}
expect(response.body).to match(/registro de bicicletas/i)
# get "/", params: {locale: :nb}
# expect(response.body).to match(/registro de bicicletas/i)
end
end

Expand All @@ -76,8 +76,8 @@
get "/", params: {}, headers: {"HTTP_ACCEPT_LANGUAGE" => "nb,en;q=0.9"}
expect(response.body).to match(/sykkelregistrering/i)

get "/", params: {}, headers: {"HTTP_ACCEPT_LANGUAGE" => "nb,en;q=0.9"}
expect(response.body).to match(/registro de bicicletas/i)
# get "/", params: {}, headers: {"HTTP_ACCEPT_LANGUAGE" => "nb,en;q=0.9"}
# expect(response.body).to match(/registro de bicicletas/i)
end
end

Expand All @@ -93,13 +93,13 @@
context "given multiple detected locales" do
include_context :request_spec_logged_in_as_user

it "gives highest precedence to query param" do
current_user.update_attribute :preferred_language, :es
get "/", params: {locale: :nl}, headers: {"HTTP_ACCEPT_LANGUAGE" => "en-US,en;q=0.9"}
expect(response.body).to match(/fietsregistratie/i)
# It doesn't reset users preferences based on request
expect(current_user.reload.preferred_language).to eq "es"
end
# it "gives highest precedence to query param" do
# current_user.update_attribute :preferred_language, :es
# get "/", params: {locale: :nl}, headers: {"HTTP_ACCEPT_LANGUAGE" => "en-US,en;q=0.9"}
# expect(response.body).to match(/fietsregistratie/i)
# # It doesn't reset users preferences based on request
# expect(current_user.reload.preferred_language).to eq "es"
# end

it "gives secondary precedence to user preference" do
current_user.update_attribute :preferred_language, :nl
Expand Down

0 comments on commit 174e9f2

Please sign in to comment.