dimanche 12 juillet 2020

Rails change locale through post in test

I have a project where I change the locale through


  scope "(:locale)", locale: /en|de/ do
    get 'home/index'
    
    namespace :admin do
      get 'login', to: 'sessions#new', as: :login
      post 'login', to: 'sessions#create'
      delete 'logout', to: 'sessions#destroy', as: :logout
      resource :account, only: [:edit, :update]
  
      root to: 'dashboard#index'
    end

    # write your routes here
    resources :users do
      resources:rides, only: %i[new create edit update destroy]
    end

    resources :rides, only: %i[show index]

    get '/login', to: 'sessions#new'
    post '/login', to: 'sessions#create'

    mount Sidekiq::Web => '/sidekiq', constraints: AdminConstraint.new
    #mount ActionCable.server => '/cable'
    root to: 'home#index'
  end
end

Now i want to write tests to test if the locale changes and I was advised to use post for that matter. Does anyone know how I would be able to do that?

Aucun commentaire:

Enregistrer un commentaire