-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #81 from loftwah/dl/avatar-border
Dl/avatar border
- Loading branch information
Showing
9 changed files
with
127 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,80 +1,90 @@ | ||
<h2 class="text-2xl font-bold mb-4">Edit <%= resource_name.to_s.humanize %></h2> | ||
|
||
<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %> | ||
<%= devise_error_messages! %> | ||
|
||
<div class="mb-2"> | ||
<%= f.label :email, class: 'block text-gray-300 mb-1' %> | ||
<%= f.email_field :email, autofocus: true, class: 'w-full p-1 rounded text-black' %> | ||
</div> | ||
|
||
<div class="mb-2"> | ||
<%= f.label :username, class: 'block text-gray-300 mb-1' %> | ||
<%= f.text_field :username, class: 'w-full p-1 rounded text-black' %> | ||
</div> | ||
|
||
<div class="mb-2"> | ||
<%= f.label :full_name, class: 'block text-gray-300 mb-1' %> | ||
<%= f.text_field :full_name, class: 'w-full p-1 rounded text-black' %> | ||
</div> | ||
|
||
<div class="mb-2"> | ||
<%= f.label :tags, class: 'block text-gray-300 mb-1' %> | ||
<%= f.text_field :tags, value: @user.parsed_tags.join(', '), class: 'w-full p-1 rounded text-black' %> | ||
</div> | ||
|
||
<div class="mb-2"> | ||
<%= f.label :avatar, class: 'block text-gray-300 mb-1' %> | ||
<%= f.text_field :avatar, class: 'w-full p-1 rounded text-black' %> | ||
</div> | ||
|
||
<div class="mb-2"> | ||
<%= f.label :banner, class: 'block text-gray-300 mb-1' %> | ||
<%= f.text_field :banner, class: 'w-full p-1 rounded text-black' %> | ||
</div> | ||
|
||
<div class="mb-2"> | ||
<%= f.label :banner_enabled, class: 'block text-gray-300 mb-1' %> | ||
<%= f.check_box :banner_enabled, class: 'rounded text-black' %> | ||
<div class="max-w-2xl mx-auto p-6 bg-gray-800 rounded-lg shadow-md"> | ||
<h2 class="text-2xl font-bold mb-6 text-lime-200">Edit <%= resource_name.to_s.humanize %></h2> | ||
|
||
<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put, class: "space-y-6" }) do |f| %> | ||
<%= devise_error_messages! %> | ||
|
||
<div> | ||
<%= f.label :email, class: 'block text-lime-200 font-semibold mb-2' %> | ||
<%= f.email_field :email, autofocus: true, class: 'block w-full px-4 py-2 border border-gray-700 rounded bg-gray-900 text-white focus:outline-none focus:border-lime-500' %> | ||
</div> | ||
|
||
<div> | ||
<%= f.label :username, class: 'block text-lime-200 font-semibold mb-2' %> | ||
<%= f.text_field :username, class: 'block w-full px-4 py-2 border border-gray-700 rounded bg-gray-900 text-white focus:outline-none focus:border-lime-500' %> | ||
</div> | ||
|
||
<div> | ||
<%= f.label :full_name, class: 'block text-lime-200 font-semibold mb-2' %> | ||
<%= f.text_field :full_name, class: 'block w-full px-4 py-2 border border-gray-700 rounded bg-gray-900 text-white focus:outline-none focus:border-lime-500' %> | ||
</div> | ||
|
||
<div> | ||
<%= f.label :tags, class: 'block text-lime-200 font-semibold mb-2' %> | ||
<%= f.text_field :tags, value: @user.parsed_tags.join(', '), class: 'block w-full px-4 py-2 border border-gray-700 rounded bg-gray-900 text-white focus:outline-none focus:border-lime-500' %> | ||
</div> | ||
|
||
<div> | ||
<%= f.label :avatar, class: 'block text-lime-200 font-semibold mb-2' %> | ||
<%= f.text_field :avatar, class: 'block w-full px-4 py-2 border border-gray-700 rounded bg-gray-900 text-white focus:outline-none focus:border-lime-500' %> | ||
</div> | ||
|
||
<div> | ||
<%= f.label :avatar_border, class: 'block text-lime-200 font-semibold mb-2' %> | ||
<%= f.select :avatar_border, options_for_select([['White', 'white'], ['Black', 'black'], ['None', 'none']], @user.avatar_border), {}, class: 'block w-full px-4 py-2 border border-gray-700 rounded bg-gray-900 text-white focus:outline-none focus:border-lime-500' %> | ||
</div> | ||
|
||
<div> | ||
<%= f.label :banner, class: 'block text-lime-200 font-semibold mb-2' %> | ||
<%= f.text_field :banner, class: 'block w-full px-4 py-2 border border-gray-700 rounded bg-gray-900 text-white focus:outline-none focus:border-lime-500' %> | ||
</div> | ||
|
||
<div class="flex items-center"> | ||
<%= f.check_box :banner_enabled, class: 'mr-2' %> | ||
<%= f.label :banner_enabled, class: 'text-lime-200 font-semibold' %> | ||
</div> | ||
|
||
<div> | ||
<%= f.label :description, class: 'block text-lime-200 font-semibold mb-2' %> | ||
<%= f.text_area :description, rows: 3, class: 'block w-full px-4 py-2 border border-gray-700 rounded bg-gray-900 text-white focus:outline-none focus:border-lime-500' %> | ||
</div> | ||
|
||
<div class="flex items-center"> | ||
<%= f.check_box :public_analytics, class: 'mr-2' %> | ||
<%= f.label :public_analytics, class: 'text-lime-200 font-semibold' %> | ||
</div> | ||
|
||
<div> | ||
<%= f.label :password, class: 'block text-lime-200 font-semibold mb-2' %> | ||
<%= f.password_field :password, autocomplete: "off", class: 'block w-full px-4 py-2 border border-gray-700 rounded bg-gray-900 text-white focus:outline-none focus:border-lime-500' %> | ||
<% if @minimum_password_length %> | ||
<p class="text-gray-400 mt-2 text-sm"><%= @minimum_password_length %> characters minimum (leave blank if you don't want to change it)</p> | ||
<% end %> | ||
</div> | ||
|
||
<div> | ||
<%= f.label :password_confirmation, class: 'block text-lime-200 font-semibold mb-2' %> | ||
<%= f.password_field :password_confirmation, autocomplete: "off", class: 'block w-full px-4 py-2 border border-gray-700 rounded bg-gray-900 text-white focus:outline-none focus:border-lime-500' %> | ||
</div> | ||
|
||
<div> | ||
<%= f.label :current_password, class: 'block text-lime-200 font-semibold mb-2' %> | ||
<%= f.password_field :current_password, autocomplete: "off", class: 'block w-full px-4 py-2 border border-gray-700 rounded bg-gray-900 text-white focus:outline-none focus:border-lime-500' %> | ||
<p class="text-gray-400 mt-2 text-sm">We need your current password to confirm your changes</p> | ||
</div> | ||
|
||
<div class="actions text-center mt-8"> | ||
<%= f.submit "Update", class: 'bg-lime-500 hover:bg-lime-600 text-white font-bold py-2 px-4 rounded-sm text-sm uppercase tracking-wide transition duration-300 ease-in-out focus:outline-none' %> | ||
</div> | ||
<% end %> | ||
|
||
<div class="mt-8 border-t border-gray-700 pt-6"> | ||
<h3 class="text-xl font-bold mb-4 text-lime-200">Cancel my account</h3> | ||
<p class="mb-4 text-gray-300">Unhappy? You can cancel your account here.</p> | ||
<%= button_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure? This action cannot be undone." }, method: :delete, class: 'bg-red-500 hover:bg-red-700 text-white font-bold py-2 px-4 rounded transition duration-300 ease-in-out' %> | ||
</div> | ||
|
||
<div class="mb-2"> | ||
<%= f.label :description, class: 'block text-gray-300 mb-1' %> | ||
<%= f.text_area :description, class: 'w-full p-1 rounded text-black' %> | ||
<div class="mt-6 text-center"> | ||
<%= link_to "Back", :back, class: 'text-lime-300 hover:text-lime-500 underline transition duration-300 ease-in-out' %> | ||
</div> | ||
|
||
<div class="field"> | ||
<%= f.label :public_analytics %> | ||
<%= f.check_box :public_analytics %> | ||
</div> | ||
|
||
<div class="mb-2"> | ||
<%= f.label :password, class: 'block text-gray-300 mb-1' %> | ||
<% if @minimum_password_length %> | ||
<em>(<%= @minimum_password_length %> characters minimum)</em> | ||
<% end %> | ||
<%= f.password_field :password, autocomplete: "off", class: 'w-full p-1 rounded text-black' %> | ||
<i>(leave blank if you don't want to change it)</i> | ||
</div> | ||
|
||
<div class="mb-2"> | ||
<%= f.label :password_confirmation, class: 'block text-gray-300 mb-1' %> | ||
<%= f.password_field :password_confirmation, autocomplete: "off", class: 'w-full p-1 rounded text-black' %> | ||
</div> | ||
|
||
<div class="mb-2"> | ||
<%= f.label :current_password, class: 'block text-gray-300 mb-1' %> | ||
<%= f.password_field :current_password, autocomplete: "off", class: 'w-full p-1 rounded text-black' %> | ||
<i>(we need your current password to confirm your changes)</i> | ||
</div> | ||
|
||
<div class="actions mb-2"> | ||
<%= f.submit "Update", class: 'bg-lime-500 hover:bg-lime-700 text-white font-bold py-1 px-2 rounded' %> | ||
</div> | ||
<% end %> | ||
|
||
<h3 class="text-xl font-bold mb-2">Cancel my account</h3> | ||
|
||
<p>Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete, class: 'bg-red-500 hover:bg-red-700 text-white font-bold py-1 px-2 rounded' %></p> | ||
|
||
<%= link_to "Back", :back, class: 'bg-gray-500 hover:bg-gray-700 text-white font-bold py-1 px-2 rounded' %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddAvatarBorderToUsers < ActiveRecord::Migration[7.1] | ||
def change | ||
add_column :users, :avatar_border, :string, default: 'white' | ||
end | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
@@ -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 | ||
|
@@ -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 | ||
|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |