* feat: v1 of the profile form * feat: fix inputs and create a handleChange event * feat: update the submit values to represent values from the form * feat: ensure that errors and success is handled on send * refactor: remove unused code * feat: replace the old profile form with a new one * fix: use the renames file * refactor: safety net for groups * chore: fix code climate issue * tests: amend + add tests * test: fix broken spec * feat: update the setup for the test * tests: refactored them to move the fake response into the before all * feat: clunky way to quickly cater for color field since it was a quick and easy implementation * feat: add a field.description to the color field * refactor: pull some duplicate code into a new function * chore: cater for a textarea field * overflow issue * refactor: use FormField instead of manual divs * Update spec/requests/users_onboarding_spec.rb Co-authored-by: Vaidehi Joshi <vaidehi.sj@gmail.com> * Update spec/requests/users_onboarding_spec.rb Co-authored-by: Vaidehi Joshi <vaidehi.sj@gmail.com> * refactor: move out of method and into a constant * refactor: user_onboarding_update to be more readable * refactor: use current.save instead of declaring a new variable * refactor: remove explicit check for bookean * refactor: use request from '@utilities/http' instead :) * refactor: no need for if with destructured groups * refactor: move color field to its own component * chore: remove colorfield now thats its a component * fix: forgot about field * feat: a text area component * chore: remove textField function in favor of component * refactor: checkbox refactor * refactor: add a switch statement * chore: move into a more organized folder * fix: move the handler to props and off from field * fix: add a conditional so we dont hit an error undefined method `success?' for nil:NilClass * refactor: change from component to function * feat: add a key attribute * refactor: add role for readers * refactor: remove unnecessary guard clauses * refactor: use function instead of an arrow * chore: document components * test * padding * fixes * test: fix the tests by using more general matchers Co-authored-by: Paweł Ludwiczak <ludwiczakpawel@gmail.com> Co-authored-by: Vaidehi Joshi <vaidehi.sj@gmail.com>
55 lines
1.7 KiB
Ruby
55 lines
1.7 KiB
Ruby
require "rails_helper"
|
|
|
|
RSpec.describe "UsersOnboarding", type: :request do
|
|
let(:user) { create(:user, saw_onboarding: false, location: "Llama Town") }
|
|
|
|
describe "PATCH /onboarding_update" do
|
|
context "when signed in" do
|
|
before { sign_in user }
|
|
|
|
it "updates saw_onboarding boolean" do
|
|
patch "/onboarding_update.json", params: {}
|
|
expect(user.saw_onboarding).to eq(true)
|
|
end
|
|
|
|
it "updates the user's last_onboarding_page attribute" do
|
|
params = { user: { last_onboarding_page: "v2: personal info form" } }
|
|
expect do
|
|
patch "/onboarding_update.json", params: params
|
|
end.to change(user, :last_onboarding_page)
|
|
end
|
|
|
|
it "does not update the user's last_onboarding_page if it is empty" do
|
|
params = { user: { last_onboarding_page: "" } }
|
|
expect do
|
|
patch "/onboarding_update.json", params: params
|
|
end.not_to change(user, :last_onboarding_page)
|
|
end
|
|
end
|
|
|
|
context "when signed out" do
|
|
it "returns a not found error if user is not signed in" do
|
|
patch "/onboarding_update.json", params: {}
|
|
expect(response.parsed_body["error"]).to include("Please sign in")
|
|
end
|
|
end
|
|
end
|
|
|
|
describe "PATCH /onboarding_checkbox_update" do
|
|
context "when signed in" do
|
|
before { sign_in user }
|
|
|
|
it "updates saw_onboarding boolean" do
|
|
patch "/onboarding_checkbox_update.json", params: {}
|
|
expect(user.saw_onboarding).to eq(true)
|
|
end
|
|
end
|
|
|
|
context "when signed out" do
|
|
it "returns a not found error if user is not signed in" do
|
|
patch "/onboarding_checkbox_update.json", params: {}
|
|
expect(response.parsed_body["error"]).to include("Please sign in")
|
|
end
|
|
end
|
|
end
|
|
end
|