Skip to content

Commit

Permalink
standardrb fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dbwinger committed Jul 1, 2024
1 parent 3617cf4 commit c01a91e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
12 changes: 6 additions & 6 deletions lib/alchemy/test_support/current_language_shared_examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,41 +5,41 @@
let!(:site_1) { create(:alchemy_site) }
let!(:site_1_default_language) { create :alchemy_language, site: site_1, default: true }
let!(:another_site_1_language) { create :alchemy_language, site: site_1, code: :de }
let(:site_2) { create :alchemy_site, host: 'another.host', languages: [build(:alchemy_language, code: :en), build(:alchemy_language, code: :de)] }
let(:site_2) { create :alchemy_site, host: "another.host", languages: [build(:alchemy_language, code: :en), build(:alchemy_language, code: :de)] }

before { session[:alchemy_language_id] = another_site_1_language.id }

context "when language ID in session is associated with the current site" do
it "sets @current_language" do
get :index, params: { site_id: site_1.id }
get :index, params: {site_id: site_1.id}
expect(assigns(:current_language)).to eq(another_site_1_language)
end
end

context "when language ID in session is not associated with the current site" do
it "sets @current_language to the current site default language" do
get :index, params: { site_id: site_2.id }
get :index, params: {site_id: site_2.id}
expect(assigns(:current_language)).to eq(site_2.default_language)
end

it "does not change the language ID in session" do
expect { get :index, params: { site_id: site_2.id } }.not_to change { session[:alchemy_language_id] }
expect { get :index, params: {site_id: site_2.id} }.not_to change { session[:alchemy_language_id] }
end
end

context "when no language ID in session" do
before { session[:alchemy_language_id] = nil }

it "sets @current_language to language language" do
get :index, params: { site_id: site_2.id }
get :index, params: {site_id: site_2.id}
expect(assigns(:current_language)).to eq site_2.default_language
end
end

context "when no language to set" do
it "shows flash warning with redirect" do
Alchemy::Language.destroy_all
get :index, params: { site_id: site_1.id }
get :index, params: {site_id: site_1.id}
expect(flash[:warning]).to eq Alchemy.t("Please create a language first.")
expect(response).to redirect_to admin_languages_path
end
Expand Down
2 changes: 0 additions & 2 deletions spec/controllers/alchemy/admin/pages_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@
end
end
end


end

describe "#destroy" do
Expand Down

0 comments on commit c01a91e

Please sign in to comment.