Discourse Ruby API testing "Unknown attribute 'auth_token' for User

I was hoping to use the Discourse API Ruby Gem and replace my SingleSignOn class with the one in there. It looks dated compared to https://github.com/discourse/discourse/blob/master/lib/single_sign_on.rb, so I was going to submit a PR to get it up to speed, but I’m stuck on setting up a test environment as noticed in the gem repo:

2. Inside of your discourse directory, run: `bundle exec rake db:api_test_seed`

When I do this I get…

~/Dev/discourse (master) $ bundle exec rake db:api_test_seed
Loading test data for discourse_api
rake aborted!
ActiveModel::UnknownAttributeError: unknown attribute 'auth_token' for User.
/Users/typeoneerror/.rvm/gems/ruby-2.4.1@discourse/gems/activemodel-5.1.4/lib/active_model/attribute_assignment.rb:48:in `_assign_attribute'
/Users/typeoneerror/.rvm/gems/ruby-2.4.1@discourse/gems/activemodel-5.1.4/lib/active_model/attribute_assignment.rb:40:in `block in _assign_attributes'
/Users/typeoneerror/.rvm/gems/ruby-2.4.1@discourse/gems/activemodel-5.1.4/lib/active_model/attribute_assignment.rb:39:in `each'
/Users/typeoneerror/.rvm/gems/ruby-2.4.1@discourse/gems/activemodel-5.1.4/lib/active_model/attribute_assignment.rb:39:in `_assign_attributes'
/Users/typeoneerror/.rvm/gems/ruby-2.4.1@discourse/gems/activerecord-5.1.4/lib/active_record/attribute_assignment.rb:26:in `_assign_attributes'
/Users/typeoneerror/.rvm/gems/ruby-2.4.1@discourse/gems/activemodel-5.1.4/lib/active_model/attribute_assignment.rb:33:in `assign_attributes'
/Users/typeoneerror/.rvm/gems/ruby-2.4.1@discourse/gems/activerecord-5.1.4/lib/active_record/core.rb:337:in `initialize'
/Users/typeoneerror/.rvm/gems/ruby-2.4.1@discourse/gems/activerecord-5.1.4/lib/active_record/inheritance.rb:66:in `new'
/Users/typeoneerror/.rvm/gems/ruby-2.4.1@discourse/gems/activerecord-5.1.4/lib/active_record/inheritance.rb:66:in `new'
/Users/typeoneerror/.rvm/gems/ruby-2.4.1@discourse/gems/activerecord-5.1.4/lib/active_record/persistence.rb:33:in `create'
/Users/typeoneerror/Dev/discourse/db/api_test_seeds.rb:1:in `<main>'
/Users/typeoneerror/.rvm/gems/ruby-2.4.1@discourse/gems/bootsnap-1.0.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `load'
/Users/typeoneerror/.rvm/gems/ruby-2.4.1@discourse/gems/bootsnap-1.0.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `load'
/Users/typeoneerror/.rvm/gems/ruby-2.4.1@discourse/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:286:in `block in load'
/Users/typeoneerror/.rvm/gems/ruby-2.4.1@discourse/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:258:in `load_dependency'
/Users/typeoneerror/.rvm/gems/ruby-2.4.1@discourse/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:286:in `load'
/Users/typeoneerror/Dev/discourse/lib/tasks/db.rake:46:in `block in <main>'
/Users/typeoneerror/.rvm/gems/ruby-2.4.1@discourse/gems/rake-12.1.0/exe/rake:27:in `<top (required)>'
/Users/typeoneerror/.rvm/gems/ruby-2.4.1@discourse/bin/ruby_executable_hooks:15:in `eval'
/Users/typeoneerror/.rvm/gems/ruby-2.4.1@discourse/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => db:api_test_seed
(See full trace by running task with --trace)

Probably an old rake task or something? What am I doing incorrectly? Do you recommend that we make our own SingleSignOn class as shown in DiscourseConnect - Official Single-Sign-On for Discourse (sso) or the Ruby Gem?

Looks like auth_token was an individual property originally and the seeding is still utilizing that instead of a has_many relationship. I might be able to fix w a PR if someone can confirm for me!

2 Likes

PR #1 https://github.com/discourse/discourse/pull/5414

4 Likes

Merged in thanks heaps! shall I close this?

Yes, you can close it, I’ll open a separate PR for the Discourse API.