Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
loftwah committed Sep 2, 2024
1 parent 3dee62f commit 578aaf6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions spec/controllers/users/registrations_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# spec/controllers/users/registrations_controller_spec.rb
require 'rails_helper'

RSpec.describe Users::RegistrationsController, type: :controller do
Expand All @@ -9,7 +8,7 @@
describe "POST #create" do
let(:valid_attributes) {
{ email: "[email protected]", password: "password", password_confirmation: "password",
username: "testuser", full_name: "Test User", tags: "tag1,tag2" }
username: "testuser", full_name: "Test User", tags: "tag1,tag2", avatar_border: "white" }
}

it "creates a new User" do
Expand All @@ -35,7 +34,7 @@

context "with valid params" do
let(:new_attributes) {
{ full_name: "New Name", tags: "new_tag1,new_tag2" }
{ full_name: "New Name", tags: "new_tag1,new_tag2", avatar_border: "black" }
}

it "updates the requested user" do
Expand All @@ -44,6 +43,7 @@
expect(user.full_name).to eq("New Name")
tags = user.tags.is_a?(String) ? JSON.parse(user.tags) : user.tags
expect(tags).to eq(["new_tag1", "new_tag2"])
expect(user.avatar_border).to eq("black")
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/factories/users.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# spec/factories/users.rb
FactoryBot.define do
factory :user do
sequence(:email) { |n| "user#{n}@example.com" }
password { "password123" }
password_confirmation { "password123" }
sequence(:username) { |n| "user#{n}" }
full_name { "Test User" }
tags { ["tag1", "tag2"] }
tags { ["tag1", "tag2"].to_json }
avatar_border { ['white', 'black', 'none'].sample }
end
end

0 comments on commit 578aaf6

Please sign in to comment.