-
Notifications
You must be signed in to change notification settings - Fork 927
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
Communities - communities #3717
base: master
Are you sure you want to change the base?
Conversation
@gravitystorm @tomhughes Can either of you enable workflows for this PR? |
app/models/client_application.rb
Outdated
@@ -39,6 +39,7 @@ class ClientApplication < ApplicationRecord | |||
|
|||
validates :key, :presence => true, :uniqueness => true | |||
validates :name, :url, :secret, :presence => true | |||
# TODO: Consider using UrlValidator from validate_url gem. |
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.
Turns out I've considered this before! But I'd forgotten about that. Unfortunately it won't work. validate_url
requires a list of permitted schemes, but for oauth callbacks any scheme needs to be allowed. See perfectline/validates_url#99
I think this comment can be removed.
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.
removed
For those who are interested in this pull request, @openbrian and I had a conversation about it a couple of weeks ago. The next steps involve working to align this with the new osm-community-index based list of communities, including topics such as how we might like to display both lists of communities, and also how to resolve the (inevitable) situation where a We also covered the need to avoid merge commits, to rebase this PR onto recent master, and to rework the PR to avoid fixup commits (and generally avoid unnecessary complexity in the history and e.g. git blame). These points are also now covered in the Pull Requests section of CONTRIBUTING.md. |
ee2085c
to
8a6ecb2
Compare
Hi @openbrian - just wondering if you've had any chance to work on this recently, or if you have any updates for us. When we discussed what was needed for reviewing this PR a few months ago, the main thing was to work on reworking the branch so that it doesn't have so many fixup commits. It'll also need rebasing onto master again, since the (other) communities branch has been merged, and we need to resolve the conflicts with that. If there's anything I can do to help, please let me know! |
@gravitystorm Indeed over the past 2 weekends, I've reduced the number of commits from 106 to about 12. I now consider myself an interactive rebase-a-holic. I'll push soon. |
I shuffled a LOT of commits. I've already rebased master and resolved conflicts. All were minor. I'd like to make sure each one build and tests successfully. I find this helps if we ever need to git-bisecting a bug. Eventually, I intend to git push --force here. Let me know if that's an issue. |
Force-pushes to PR branches are completely welcome, no issue with that whatsoever. |
8afa8e6
to
93763d0
Compare
Failing here diff -uw db/structure.expected db/structure.actual. I'll have to make sure to get the order of the SQL statement right. |
93763d0
to
6097680
Compare
Fixed the ordering of statements in db/structure.sql. Will work on other checks next. |
a71d408
to
22c4492
Compare
38106a3
to
33a56ab
Compare
5d60113
to
430899f
Compare
430899f
to
2921f5d
Compare
2921f5d
to
2eb53c1
Compare
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 only a partial review, since it's a big PR and I've run out of time today.
A few other thoughts here as a reminder for myself for the next review:
- Resolve communities vs communities name clash
- Consider if communities is already overloaded in the wider osm community e.g. community.osm.org etc
- list of commits still has fixup commits
- javascript etc unreviewed
- can this be slimmed down further e.g. move clever sorting to followup PR etc
config/routes.rb
Outdated
@@ -147,7 +147,7 @@ | |||
get "/help" => "site#help" | |||
get "/about/:about_locale" => "site#about" | |||
get "/about" => "site#about" | |||
get "/communities" => "site#communities" | |||
get "/community_index" => "site#communities" |
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.
We need to think carefully about doing this, since it would break all external links to the existing communities page.
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.
Understood. Let's look at the dev site when it's up and running to find the best solution.
The thing is communities is a route resource, so it will get a /communities URL. Maybe that can be customized to avoid this collision.
config/routes.rb
Outdated
# user nested resources | ||
resources :users, :path => "user", :param => :display_name do | ||
resources :communities, :only => [:index] | ||
end |
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 could be combined with the existing resources :users
statement, so that resources :users
isn't defined twice
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.
will do
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.
done
def test_edit_get_no_session | ||
# arrange | ||
c = create(:community) | ||
# act | ||
get edit_community_path(c) | ||
# assert | ||
assert_response :redirect | ||
assert_redirected_to login_path(:referer => edit_community_path(c)) | ||
end |
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 don't think the hundreds of repeated # arrange
, # act
, # assert
comments are helpful - they are just more text to read and maintain (e.g. when refactoring tests).
I suggest removing the # arrange
comments entirely, and changing the other two to blank lines. For example:
def test_edit_get_no_session
c = create(:community)
get edit_community_path(c)
assert_response :redirect
assert_redirected_to login_path(:referer => edit_community_path(c))
end
This keeps the readability of having the three sections being distinct from one another, but with less clutter.
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 can do that. Just to be clear, it is a unit test design pattern that goes back 20 years. http://wiki.c2.com/?ArrangeActAssert
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.
Sure, the pattern is good, full agreement there. But as the link you gave also suggests, please use blank lines rather than comments:
"Each method should group these functional sections, separated by blank lines: "
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.
done
app/models/community_link.rb
Outdated
|
||
class CommunityLink < ApplicationRecord | ||
belongs_to :community | ||
validates :site, :presence => true, :length => 1..255, :characters => true |
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.
From previous review, "site" here is not clear. Perhaps one of: name, label, text.
(You previously suggested "link" but I think that's even more confusing with "link" vs "url"!)
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.
"text" - done
config/locales/en.yml
Outdated
label: | ||
community: | ||
description: "Description" | ||
lat: "Latitude" |
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 thought the model had attributes of "latitude", not "lat"? Same for lon.
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.
Fixed
config/locales/en.yml
Outdated
submit: | ||
community: | ||
create: "Create Community" |
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.
Isn't "Create %{model_name}" the default here?
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.
Removed.
lib/osm.rb
Outdated
@@ -527,4 +527,9 @@ def self.http_client | |||
def self.maxmind_database | |||
@maxmind_database ||= MaxMindDB.new(Settings.maxmind_database) if Settings.key?(:maxmind_database) | |||
end | |||
|
|||
# Convert any longitude input to the range -180..180. | |||
def self.normalize_longitude(longitude_in) |
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.
just longitude
since there's no other longitude in this function
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.
fixed
test/abilities/abilities_test.rb
Outdated
@@ -59,6 +71,15 @@ class UserAbilityTest < AbilityTest | |||
assert ability.cannot?(action, Issue), "should not be able to #{action} Issues" | |||
end | |||
end | |||
|
|||
# This does not take into account object level access control. |
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.
note to self: should it?
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.
Yes. Anyone can create a community. But a community can only be edited by its owner. I've added test cases.
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.
done
test/factories/communities.rb
Outdated
lat1 = Random.rand(-90.0..90.0) | ||
lat2 = Random.rand(-90.0..90.0) | ||
lat1, lat2 = lat2, lat1 if lat2 < lat1 |
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.
A more compact version, using sort:
lat1, lat2 = [Random.rand(-90.0..90.0), Random.rand(-90.0..90.0)].sort
To avoid duplicating the random number bit, you can use an Array construction with a block, but it's perhaps less readable? Probably a personal preference between these two.
lat1, lat2 = Array.new(2) { Random.rand(-90.0..90.0) }.sort
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, I went with the Array construction with a block.
Thanks for the feedback so far. |
LGTM!!! |
c7b51f1
to
65caec0
Compare
I've removed all references to "microcosm". I've consolidated all commits into 2 commits:
Later PRs will have members, events, and rsvps. |
7c41be5
to
468d58c
Compare
a002e2b
to
c5f7dca
Compare
1f84b71
to
9dd48e9
Compare
While a community will eventually have multiple organizers, we need at least one person to be responsible if an issue is raised. The community has one owner. In later PRs, there will be multiple members and multiple organizers.
9dd48e9
to
1f59d7c
Compare
Links must be https. Add validate_url ruby gem to validate the urls. Add not null on link site and url. Add relevant FK.
1f59d7c
to
706667e
Compare
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'm at a bit of a loss how to approach this review, since the diff is huge (1700+ additions).
So we could do this in two ways - I can go through the details (e.g. <label>
should only be used for forms, it shouldn't have custom CSS, the <h1>
in communities#index uses lego translations etc) or we can tackle the big picture (e.g. renaming the existing Communities model/controller, whether we want Yet Another OSM Thing Called Communities, etc).
What would be more helpful? Or should I just send you a stream of feedback as I go?
resources :communities do | ||
resources :community_links, :only => [:create, :index, :new] | ||
end | ||
resources :community_links, :only => [:destroy, :edit, :update] |
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.
Doesn't :shallow
option of resources
do the same thing?
Microcosms was renamed to communities See #3683 for the PR before this one.