mirror of
https://github.com/basecamp/once-campfire.git
synced 2026-04-20 11:11:50 +09:00
Give up on the auto delegation to get a cleaner API
This commit is contained in:
2
Gemfile
2
Gemfile
@@ -3,7 +3,7 @@ source "https://rubygems.org"
|
||||
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
||||
|
||||
# Rails
|
||||
gem "rails", github: "rails/rails", ref: "7727f43d38bf1783550e7a47207a9548e34a2c25" # branch: "main"
|
||||
gem "rails", github: "rails/rails", ref: "478abdb62b4ff769ae2d9cf2e34be8335d9b6f7e" # branch: "main"
|
||||
gem "ostruct"
|
||||
gem "benchmark"
|
||||
|
||||
|
||||
@@ -26,8 +26,8 @@ GIT
|
||||
|
||||
GIT
|
||||
remote: https://github.com/rails/rails.git
|
||||
revision: 7727f43d38bf1783550e7a47207a9548e34a2c25
|
||||
ref: 7727f43d38bf1783550e7a47207a9548e34a2c25
|
||||
revision: 478abdb62b4ff769ae2d9cf2e34be8335d9b6f7e
|
||||
ref: 478abdb62b4ff769ae2d9cf2e34be8335d9b6f7e
|
||||
specs:
|
||||
actioncable (8.2.0.alpha)
|
||||
actionpack (= 8.2.0.alpha)
|
||||
|
||||
@@ -2,5 +2,5 @@ class Account < ApplicationRecord
|
||||
include Joinable
|
||||
|
||||
has_one_attached :logo
|
||||
has_json :settings, schema: { restrict_room_creation_to_administrators: false }, delegate: true
|
||||
has_json :settings, restrict_room_creation_to_administrators: false
|
||||
end
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% if Current.account.restrict_room_creation_to_administrators? %>
|
||||
<% if Current.account.settings.restrict_room_creation_to_administrators? %>
|
||||
<%= button_to_toggle_setting "Allow everyone to create new rooms", :restrict_room_creation_to_administrators %>
|
||||
<% else %>
|
||||
<%= button_to_toggle_setting "Only allow admins to create new rooms", :restrict_room_creation_to_administrators %>
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<% if Current.user.administrator? || !Current.account.restrict_room_creation_to_administrators? %>
|
||||
<% if Current.user.administrator? || !Current.account.settings.restrict_room_creation_to_administrators? %>
|
||||
<%= link_to new_rooms_open_path, class: "rooms__new-btn btn room align-center gap txt-reversed", aria: { label: "New Chat Room" } do %>
|
||||
<%= image_tag "add.svg", size: 20, aria: { hidden: "true" }, style: "view-transition-name: new-room" %>
|
||||
<% end %>
|
||||
|
||||
@@ -2,18 +2,18 @@ require "test_helper"
|
||||
|
||||
class AccountTest < ActiveSupport::TestCase
|
||||
test "settings" do
|
||||
accounts(:signal).restrict_room_creation_to_administrators = true
|
||||
assert accounts(:signal).restrict_room_creation_to_administrators?
|
||||
accounts(:signal).settings.restrict_room_creation_to_administrators = true
|
||||
assert accounts(:signal).settings.restrict_room_creation_to_administrators?
|
||||
assert_equal({ "restrict_room_creation_to_administrators" => true }, accounts(:signal)[:settings])
|
||||
|
||||
accounts(:signal).update!(settings: { "restrict_room_creation_to_administrators" => "true" })
|
||||
assert accounts(:signal).reload.restrict_room_creation_to_administrators?
|
||||
assert accounts(:signal).reload.settings.restrict_room_creation_to_administrators?
|
||||
|
||||
accounts(:signal).restrict_room_creation_to_administrators = false
|
||||
assert_not accounts(:signal).restrict_room_creation_to_administrators?
|
||||
accounts(:signal).settings.restrict_room_creation_to_administrators = false
|
||||
assert_not accounts(:signal).settings.restrict_room_creation_to_administrators?
|
||||
assert_equal({ "restrict_room_creation_to_administrators" => false }, accounts(:signal)[:settings])
|
||||
accounts(:signal).update!(settings: { "restrict_room_creation_to_administrators" => "false" })
|
||||
assert_not accounts(:signal).reload.restrict_room_creation_to_administrators?
|
||||
assert_not accounts(:signal).reload.settings.restrict_room_creation_to_administrators?
|
||||
end
|
||||
|
||||
test "default settings" do
|
||||
|
||||
Reference in New Issue
Block a user