mirror of
https://github.com/lunaisnotaboy/mastodon.git
synced 2024-11-17 12:24:31 +00:00
Coverage for api/web/settings controller (#3238)
This commit is contained in:
parent
e1b42e9aa0
commit
a28ce13b3e
|
@ -6,10 +6,15 @@ class Api::Web::SettingsController < ApiController
|
||||||
before_action :require_user!
|
before_action :require_user!
|
||||||
|
|
||||||
def update
|
def update
|
||||||
setting = ::Web::Setting.where(user: current_user).first_or_initialize(user: current_user)
|
|
||||||
setting.data = params[:data]
|
setting.data = params[:data]
|
||||||
setting.save!
|
setting.save!
|
||||||
|
|
||||||
render_empty
|
render_empty
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def setting
|
||||||
|
@_setting ||= ::Web::Setting.where(user: current_user).first_or_initialize(user: current_user)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
24
spec/controllers/api/web/settings_controller_spec.rb
Normal file
24
spec/controllers/api/web/settings_controller_spec.rb
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
describe Api::Web::SettingsController do
|
||||||
|
render_views
|
||||||
|
|
||||||
|
let!(:user) { Fabricate(:user) }
|
||||||
|
|
||||||
|
describe 'PATCH #update' do
|
||||||
|
it 'redirects to about page' do
|
||||||
|
sign_in(user)
|
||||||
|
patch :update, format: :json, params: { data: { 'onboarded' => true } }
|
||||||
|
|
||||||
|
user.reload
|
||||||
|
expect(response).to have_http_status(:success)
|
||||||
|
expect(user_web_setting.data['onboarded']).to eq('true')
|
||||||
|
end
|
||||||
|
|
||||||
|
def user_web_setting
|
||||||
|
Web::Setting.where(user: user).first
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue