ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -


i have built module in solidus , ruby on rails , try create tests.

i trying create integration tests , have error:

e error: prescriptionphotostest#test_/prescription_photos_post_endpoint_throws_an_error_when_wrong_params: argumenterror: missing host link to! please provide :host parameter, set default_url_options[:host], or set :only_path true test/integration/prescription_photos_test.rb:6:in `block in '

i read this , this, doesn't make difference.

my code returning error on line:

@user = factorygirl.create(:user)

here code files.

prescription_photos_rest.rb

require 'test_helper'  class prescriptionphotostest < actiondispatch::integrationtest   setup     spree::auth::config[:confirmable] = false     @user = factorygirl.create(:user)   end    def authenticated_header     token = knock::authtoken.new(payload: { sub: @user.id }).token     {         'authorization': "bearer #{token}"     }   end    test '/prescription_photos post endpoint throws error when wrong params'      post '/api/prescription_photos', headers: authenticated_header, params: {        something: {            is: 'wrong'        }      }      json = json.parse(body)       assert_response 422      assert json.has_key? 'exception'      assert_equal 'param missing or value empty: prescription', json['exception']   end end 

factories.rb

factorygirl.define   factory :user, class: spree::user     email 'test@test.nl'     password 'test123'     password_confirmation 'test123'   end end 

test_helper.rb

env['rails_env'] ||= 'test' require file.expand_path('../../config/environment', __file__) require 'rails/test_help'  class activesupport::testcase   # setup fixtures in test/fixtures/*.yml tests in alphabetical order.   fixtures :all   # add more helper methods used tests here... end 

test.rb

rails.application.configure   # settings specified here take precedence on in config/application.rb.   config.action_controller.default_url_options = { host: 'localhost', port: 3000 }    # test environment used exclusively run application's   # test suite. never need work otherwise. remember   # test database "scratch space" test suite , wiped   # , recreated between test runs. don't rely on data there!   config.cache_classes = true    # not eager load code on boot. avoids loading whole application   # purpose of running single test. if using tool   # preloads rails running tests, may have set true.   config.eager_load = false    # configure public file server tests cache-control performance.   config.public_file_server.enabled = true   config.public_file_server.headers = {     'cache-control' => 'public, max-age=3600'   }    # show full error reports , disable caching.   config.consider_all_requests_local       = true   config.action_controller.perform_caching = false    # raise exceptions instead of rendering exception templates.   config.action_dispatch.show_exceptions = false    # disable request forgery protection in test environment.   config.action_controller.allow_forgery_protection = false   config.action_mailer.perform_caching = false    # add host parameter   config.action_mailer.default_url_options = { host: 'localhost' }    # tell action mailer not deliver emails real world.   # :test delivery method accumulates sent emails in   # actionmailer::base.deliveries array.   config.action_mailer.delivery_method = :test    # print deprecation notices stderr.   config.active_support.deprecation = :stderr    # raises error missing translations   # config.action_view.raise_on_missing_translations = true end 

after running rake test:integration got error mentioned above.

i did lot of googleing , tried fix problem in past 2 days, had no luck.

spree::auth::config[:confirmable] = false 

this line of code prescription_photos_rest.rb overwritten buy env value.


Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -