-
-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
✨ Space
add "Website Settings" section and enforce ssl checkbox
#1484
Conversation
Test Cases to test on Local
|
@zspencer I forgot to ask you where on the |
It feels like we're starting to need a new "general space settings" section. (With maybe a better / more concise title, probably.) |
For now an "Operator Only Settings" section feels like maybe the right place; that way we could also expose the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great direction! Hopefully the comments I left were useful!
app/views/space_invitation_mailer/space_invitation_email.text.erb
Outdated
Show resolved
Hide resolved
Will continue on sunday 5/21 |
@zspencer should I add browser tests or any unit tests for the new "Operator Only Settings" section? Or is it too early |
Space
add enforce ssl checkboxSpace
add "Operator Only Settings" section and enforce ssl checkbox
Space
add "Operator Only Settings" section and enforce ssl checkboxSpace
add "Operator Only Settings" section and enforce ssl checkbox
It would be good to have a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So long as you have confirmed that the data flips when the form submits I am comfortable with you merging this.
Maybe this is actually "Website Settings" and not "Operator Only Settings" 🙃 |
Space
add "Operator Only Settings" section and enforce ssl checkboxSpace
add "Website Settings" section and enforce ssl checkbox
Renamed to "Website Settings" in the code and UI in 5910f5c |
app/controllers/spaces_controller.rb
Outdated
elsif params[:enforce_ssl] == 1 | ||
policy_scope(Space).friendly.find(params[:id]).update(enforce_ssl: true) | ||
elsif params[:enforce_ssl] == 0 | ||
policy_scope(Space).friendly.find(params[:id]).update(enforce_ssl: false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this is the correct way to update Space
record based on the checkbox value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, this does seem a little off-the-rails to me. Normally, if space_params
includes enforce_ssl
it will update just fine from the browser without needing to do a comparison check; so you shouldn't have to change the controller since you're permitting the new param in the SpacePolicy
.
new_entrance = space.rooms.sample | ||
put polymorphic_path(space), params: {space: {entrance_id: new_entrance.id, enforce_ssl: 0}} | ||
|
||
expect(space.enforce_ssl).to be false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests still fail. IDK why.
I see the Space
record updating enforce_ssl
to the correct value in Puma logs when submitting the form on local.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both the Controller
space
instance and the spec
space
instance have the same id
(since they're referencing the same piece of data where it's stored in the database) but will have a different location in memory; so changes to the space
instance in the Controller
will only be reflected in space
instance in the spec
once the space
instance in the spec
re-queries the database to get the updated value.
TL/DR: You may want to call space.reload
after executing the put
because the computer caches the data in the Space
record independently between the Controller
and spec
until it is re-queried..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is good progress; and would be happy to merge it once the tests pass. That said; there are a couple ways to bring this closer to "Rails-normal":
- Revert the changes in
SpacesController
- Use
true
andfalse
in yourspaces_controller_request_spec
app/controllers/spaces_controller.rb
Outdated
elsif params[:enforce_ssl] == 1 | ||
policy_scope(Space).friendly.find(params[:id]).update(enforce_ssl: true) | ||
elsif params[:enforce_ssl] == 0 | ||
policy_scope(Space).friendly.find(params[:id]).update(enforce_ssl: false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, this does seem a little off-the-rails to me. Normally, if space_params
includes enforce_ssl
it will update just fine from the browser without needing to do a comparison check; so you shouldn't have to change the controller since you're permitting the new param in the SpacePolicy
.
<%= web_settings_form.check_box :enforce_ssl %> | ||
Enforce SSL - Automatically redirects all Visitor traffic to this Space to https. | ||
<% end %> | ||
<%= web_settings_form.submit %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice
new_entrance = space.rooms.sample | ||
put polymorphic_path(space), params: {space: {entrance_id: new_entrance.id, enforce_ssl: 0}} | ||
|
||
expect(space.enforce_ssl).to be false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both the Controller
space
instance and the spec
space
instance have the same id
(since they're referencing the same piece of data where it's stored in the database) but will have a different location in memory; so changes to the space
instance in the Controller
will only be reflected in space
instance in the spec
once the space
instance in the spec
re-queries the database to get the updated value.
TL/DR: You may want to call space.reload
after executing the put
because the computer caches the data in the Space
record independently between the Controller
and spec
until it is re-queried..
|
||
it "enables Enforce SSL on a Space" do | ||
new_entrance = space.rooms.sample | ||
put polymorphic_path(space), params: {space: {entrance_id: new_entrance.id, enforce_ssl: 1}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use false
and true
in your params (and it is generally preferred)
and fix unit tests. Co-authored-by: Zee Spencer <zspencer@users.noreply.github.com> Co-authored-by: Ana <anaulin@users.noreply.github.com> Co-authored-by: Dalton Pruitt <daltonrpruitt@users.noreply.github.com>
Spaces
: Enforcessl
connection #1473Changes
Spaces
edit page:enforce_ssl
permitted paramspaces
tableenforce_ssl
with the checkbox value boolean (dependent on to ✨ 🥔 🥗Spaces
add Enforce_SSL flag #1479)