Skip to content
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

Add microcosms to the website #2390

Closed
wants to merge 299 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
299 commits
Select commit Hold shift + click to select a range
baea771
Replace link to geofabrik with TODO item to get the bounding box.
openbrian Oct 15, 2019
3c391b9
rubocop hash rockets
openbrian Oct 15, 2019
8f151f4
Adding rspec for now. Will likely change to minitest later, because …
openbrian Oct 15, 2019
cde9c20
save returns true or false, save! returns true or throws an exception.
openbrian Oct 15, 2019
8d9f23d
Forgot to add the lock file.
openbrian Oct 15, 2019
60dd7ff
Merge branch 'master' into microcosms
openbrian Oct 15, 2019
bae65fa
Translate all the things.
openbrian Oct 17, 2019
5b2dea4
The I18N change broke a test, so fix that. Also change the wording o…
openbrian Oct 18, 2019
e8dd6ea
Change lat and lon from decimal to integer.
openbrian Oct 18, 2019
57849ec
Use router paths instead of hard coded urls.
openbrian Oct 18, 2019
d4f236b
use find_by instead of find_by_name
openbrian Oct 18, 2019
2aa3421
When setting up my database, I never created these pl/pgsql functions…
openbrian Oct 18, 2019
01d2560
Remove extra dashes.
openbrian Oct 18, 2019
166ce93
Restore having inet_ops modifier on the index for acls.
openbrian Oct 18, 2019
41541a5
Clean up accidental change to this index's opclass.
openbrian Oct 18, 2019
d5b0c54
Merge branch 'master' into microcosms
openbrian Oct 21, 2019
a16acdd
Merge branch 'master' into microcosms
openbrian Oct 25, 2019
6df2adc
Add code coverage.
openbrian Oct 25, 2019
8fff5fc
Add html5shiv to manifest.js.
openbrian Oct 25, 2019
e4e695b
Move coveralls requirements from rake file to env file.
openbrian Oct 25, 2019
428ad56
Move require coveralls up.
openbrian Oct 27, 2019
a0490c4
dummy whitespace to trigger a build
openbrian Oct 27, 2019
88e6a73
Make sure all tests run.
openbrian Oct 27, 2019
54a8311
Merge branch 'microcosms' of github.com:openbrian/osm-microcosms into…
openbrian Oct 30, 2019
a30d9fe
Merge branch 'master' into microcosms
openbrian Oct 30, 2019
4ace0bd
Merge branch 'master' into microcosms
openbrian Jan 20, 2020
7c11220
Deal with whitespace issue.
openbrian Jan 20, 2020
5aee2c2
Restore Gemfile.lock to BUNDLED WITH 1.17.2.
openbrian Jan 20, 2020
5ce2836
Resolve this "Setting NOT NULL on a column requires an AccessExclusiv…
openbrian Jan 20, 2020
49bdd4e
Merge branch 'master' into microcosms
openbrian Jan 20, 2020
3d7c346
There's an ApplicationRecord base class finally.
openbrian Jan 20, 2020
0e8d720
whitespace
openbrian Jan 20, 2020
de21fba
Rebuild database structure file.
openbrian Jan 20, 2020
a823157
Revert "Rebuild database structure file."
openbrian Jan 23, 2020
d319e31
Use slashed.
openbrian Jan 23, 2020
0cae928
Update structure.sql according to last migration change.
openbrian Jan 23, 2020
3c6207e
Rubocop appeasement.
openbrian Jan 25, 2020
4ab9a5d
Clean up this extra IMMUABLE keyword.
openbrian Jan 26, 2020
0ccc215
localize events heading
openbrian Jan 27, 2020
9fd38c2
Add event organizers.
openbrian Jan 27, 2020
34b43c1
Add event organizers.
openbrian Jan 27, 2020
0826f36
Merge branch 'microcosms' of github.com:openbrian/osm-microcosms into…
openbrian Jan 27, 2020
107c390
whitespace/lint cleanups
openbrian Jan 28, 2020
8479c71
Forgot to include the migration
openbrian Jan 28, 2020
af1ff77
rubocop
openbrian Jan 28, 2020
cb59e8c
Add a test to view a list of events, both all events and microcosm ev…
openbrian Jan 28, 2020
e2ee403
Replace hardcoded image of map with a leaflet map. Write an automate…
openbrian Jan 31, 2020
6fa26ac
Remove .report-disclaimer. This snuck its way in from some merge wit…
openbrian Feb 1, 2020
75cc760
Replace .flex_row with bootstrap row which is also flex-based.
openbrian Feb 1, 2020
81ff338
Replace custom styles with bootstrappy .card style. Put this in a he…
openbrian Feb 1, 2020
d47d9a1
Use .user_cards for event attendances too.
openbrian Feb 1, 2020
1de5ce5
Minor scss improvement and add a comment.
openbrian Feb 1, 2020
789620e
Remove unused stylesheet files until they are needed.
openbrian Feb 1, 2020
183e19c
My mistake, rspec is not needed.
openbrian Feb 1, 2020
eaded21
Merge remote-tracking branch 'upstream/master' into microcosms
openbrian Feb 1, 2020
4b858a2
Use Titus Fortner's webdrivers module instead of installing geckodriver.
openbrian Feb 1, 2020
ad64bc8
expect() comes from rspec. This should have been removed, but I had …
openbrian Feb 2, 2020
b5ef4e2
quotes
openbrian Feb 2, 2020
39dc4f5
erblint fix
openbrian Feb 2, 2020
9d85ab0
Add FK references where needed. Drop facebook and twitter columns fr…
openbrian Feb 2, 2020
c8ccb9b
add a comment about possibly using a transation
openbrian Feb 2, 2020
cd14b08
Header should contain the name of the microcosm. Forgot to commit th…
openbrian Feb 3, 2020
98991f3
Change microcosm attributes lat and lon to latitude and longitude in …
openbrian Feb 3, 2020
0e70136
rubocop cleanups
openbrian Feb 3, 2020
a762fb3
One line methods need a semicolon.
openbrian Feb 3, 2020
e483197
Webmock is blocking the titusfortner/webdrivers' call to download the…
openbrian Feb 3, 2020
58ab30e
Revert "Webmock is blocking the titusfortner/webdrivers' call to down…
openbrian Feb 5, 2020
63c2edf
Take out webdrivers for now.
openbrian Feb 5, 2020
92d9ea6
Disable the javascript based test until we get a webdriver installed.…
openbrian Feb 5, 2020
31db02b
hashtag
openbrian Feb 5, 2020
52c7bcb
Merge branch 'master' into microcosms
openbrian Feb 5, 2020
57c7000
Forgot to commit lock file.
openbrian Feb 5, 2020
6bd752f
div should have been h5
openbrian Feb 5, 2020
c7daeb1
Replace hard coded changesets with real ones. Change coordinates to …
openbrian Feb 13, 2020
0de5e80
Merge remote-tracking branch 'upstream/master' into microcosms
openbrian Feb 13, 2020
4f28cec
rubocop cleanups
openbrian Feb 13, 2020
c4f3ff6
Add location_url, latitude, and longitude to events. Replace hard co…
openbrian Feb 15, 2020
dd446f4
Add some validation and model testing for microcosms.
openbrian Feb 15, 2020
2d9b6da
udpate_tile is no longer needed.
openbrian Feb 15, 2020
43f2b9e
Add validation and model test for microcosm_member. Rename microcosm…
openbrian Feb 16, 2020
a219cfd
typo
openbrian Feb 16, 2020
f157b84
Fix translations
openbrian Feb 16, 2020
eb448d5
Hide Join button if already a member. Fix missing translations.
openbrian Feb 16, 2020
2fac11b
rubocop
openbrian Feb 16, 2020
bcd2289
Merge remote-tracking branch 'upstream/master' into microcosms
openbrian Feb 16, 2020
1acb41c
add missing file
openbrian Feb 16, 2020
fd596f6
whitespace
openbrian Feb 16, 2020
581d684
Add validation and model test for microcosm_link. Add validate_url r…
openbrian Feb 16, 2020
5c4e476
Evidently can't use es6 syntax.
openbrian Feb 16, 2020
b74fd70
Add validation for microcosm locations.
openbrian Feb 16, 2020
3b0a35c
Create validation and model test for events. Improve factory.
openbrian Feb 19, 2020
ed40d18
Merge remote-tracking branch 'upstream/master' into microcosms
openbrian Feb 19, 2020
e95fa3f
Add missing colon for null symbol.
openbrian Feb 19, 2020
594688c
rubocop
openbrian Feb 19, 2020
4c39e32
eslint cleanups
openbrian Feb 20, 2020
844eaeb
Convert blank input to nil. Allow nil for event coords.
openbrian Feb 21, 2020
2a603dc
Allow organizers to edit an event.
openbrian May 2, 2020
9f4bf54
Microcosm descriptions are not allowed to be nil/empty.
openbrian May 2, 2020
198d5c0
Merge branch 'master' into microcosms
openbrian May 2, 2020
a6a6ff9
Merge branch 'master' into microcosms
openbrian May 13, 2020
7e82139
Merge branch 'master' into microcosms
openbrian May 13, 2020
d1b43d5
Merge branch 'microcosms' of github.com:openbrian/osm-microcosms into…
openbrian May 13, 2020
8b1088c
Some rubocop fixes.
openbrian May 14, 2020
5b9f17e
Include mime-type
openbrian May 14, 2020
43bd03a
When running these migrations the table will be empty, so adding 3 co…
openbrian May 14, 2020
6b2e422
2 more rubocops and update db/structure.sql to match migrations.
openbrian May 14, 2020
2f629f1
Move NOT NULL to the correct table
openbrian May 14, 2020
e552223
Merge branch 'master' into microcosms
openbrian May 21, 2020
9c6394f
Add tests for microcosm and event_organizer.
openbrian May 23, 2020
709bef1
buml libxml-ruby.
openbrian May 23, 2020
ee74b35
Fix gemfile.lock?
openbrian May 23, 2020
4fc8fcf
That was dumb. Undo that.
openbrian May 25, 2020
f0e0d05
Merge branch 'master' into microcosms
openbrian May 25, 2020
090dcad
fix test
openbrian May 25, 2020
6a5dac0
Remove cucumber tests.
openbrian May 26, 2020
2c84671
rubocop fixes
openbrian May 26, 2020
716daa1
Add missing entry for microcosms in compact-secondary-nav
openbrian May 26, 2020
a062cb5
Using feature flag for dev instance, add a link for feedback to micro…
openbrian May 26, 2020
381398d
remove feature flag for feedback. hardcode for now
openbrian May 26, 2020
e312aee
allow anyone to create a microcosm. For now?
openbrian May 26, 2020
7292cbd
rubocop got pissy about indentation
openbrian May 26, 2020
5283fb9
Move microcosm :new, :create to non-admin. :update is already there …
openbrian May 27, 2020
1a5a70f
Add instruction, all fields are required.
openbrian May 27, 2020
036352c
add hint for location
openbrian May 27, 2020
e6ba9e3
Order microcosms by longitude.
openbrian May 27, 2020
5cd9de1
Remove inline javascript to comply with CSP. Move that logic to micr…
openbrian May 27, 2020
ae8de78
Order of members needs to be deterministic for automated testing. Or…
openbrian May 28, 2020
f4392b3
Allow non-admins to create a microcosm and become the organizer of it.
openbrian May 28, 2020
b623894
whitespace
openbrian May 28, 2020
a95eba3
Add todo note about scopes with organizers
openbrian May 28, 2020
e25f1dd
Dev has 2 microcosms that have no organizers. There's no admin who c…
openbrian May 28, 2020
88183a9
Remove debugging.
openbrian May 29, 2020
6283e09
Since there are duplicate memberships on dev, we must be able to remo…
openbrian May 29, 2020
bc235a1
It's ok to have a user as both a member and an organizer. Let only n…
openbrian May 31, 2020
aa9f98d
Use non-ajax for joining a microcosm.
openbrian May 31, 2020
2d4c395
Add a bunch of tests for microcosm_controller. This is not complete.…
openbrian Jun 1, 2020
8a7e921
test microcosm update
openbrian Jun 1, 2020
bdcff76
rubocop
openbrian Jun 1, 2020
5bd96db
Add more tests. I prefer @title so templates don't need to call func…
openbrian Jun 3, 2020
286b562
Merge branch 'microcosms' of github.com:openbrian/osm-microcosms into…
openbrian Jun 3, 2020
3e01261
Add a test for microcosm#create.
openbrian Jun 5, 2020
eba59c4
Merge branch 'master' into microcosms
openbrian Jun 5, 2020
b9c317b
Downgrade due to rubocop bug.
openbrian Jun 5, 2020
bbf399e
add a test for add_first_organizer
openbrian Jun 6, 2020
18a9e32
Add tests for stepping up
openbrian Jun 6, 2020
6434955
Make the forms look like the rest of the website.
openbrian Jun 6, 2020
fb2dd4d
Do not use ajax for event attendance form submission
openbrian Jun 6, 2020
066dfee
Hide 1 button
openbrian Jun 6, 2020
348ae17
Move temporary feedback link from header to a banner.
openbrian Jun 7, 2020
d3bfaf3
Make microcosm index look better. Move edit link from index to show.
openbrian Jun 7, 2020
07584af
Make events index page look better. Show only future events.
openbrian Jun 7, 2020
19c163f
Make event list look better. Move edit link from show to index. Fac…
openbrian Jun 7, 2020
e779231
Modify UI for mobile.
openbrian Jun 7, 2020
b3877bb
Factor out formMapInput from event/new form and let microcosm/new als…
openbrian Jun 8, 2020
24daf4b
Merge branch 'master' into microcosms
openbrian Jun 8, 2020
a7caab4
Make members and events page look better. Make sure events are order…
openbrian Jun 9, 2020
596fd5f
Make display_names on user_cards overflow.
openbrian Jun 9, 2020
1c832e9
Display if the changeset has review_requested.
openbrian Jun 9, 2020
764563f
Sort by longitude and time of day
openbrian Jun 9, 2020
719891f
remove multiple new lines at end of file
openbrian Jun 9, 2020
0a771af
Remove debugging in event show page
openbrian Jun 9, 2020
25be397
Add tests for 4 methods in event model.
openbrian Jun 20, 2020
8846d6e
Add tests for event helper
openbrian Jun 20, 2020
ebe798d
add test for event organizers
openbrian Jun 20, 2020
6d507c6
use regex for assert_match, strings work, but not sure where the issu…
openbrian Jun 20, 2020
1e01948
I learned it by watching you (note_helper_test.rb) (https://en.wikipe…
openbrian Jun 20, 2020
93f99fb
Merge remote-tracking branch 'upstream/master'
openbrian Jun 20, 2020
5ffd24c
Merge branch 'master' into microcosms
openbrian Jun 20, 2020
f1e91aa
Event helper test must have dynamic location_url and location for mat…
openbrian Jun 21, 2020
9853b66
start adding tests for event controller
openbrian Jun 21, 2020
92ca1e0
whitespace
openbrian Jun 21, 2020
1eea6dc
Merge remote-tracking branch 'upstream/master'
openbrian Jun 21, 2020
5448f4f
Merge branch 'master' into microcosms
openbrian Jun 21, 2020
ce85eb7
Add more event_controller tests.
openbrian Jun 22, 2020
ed3aa69
Add tests for event_controller update
openbrian Jun 26, 2020
ceee596
Merge branch 'master' into microcosms
openbrian Jun 26, 2020
5a81c50
Add test for events show
openbrian Jun 28, 2020
4c504ef
Use Arel.sql() for order() because this is a known safe value
openbrian Jun 28, 2020
88290df
show was already there
openbrian Jun 28, 2020
4052ac9
Merge branch 'master' of github.com:openbrian/osm-microcosms
openbrian Jun 28, 2020
587ebde
Merge branch 'master' into microcosms
openbrian Jun 28, 2020
d44455a
Merge remote-tracking branch 'upstream/master'
openbrian Jun 30, 2020
573ae4a
Merge branch 'master' into microcosms
openbrian Jun 30, 2020
7df0df2
Use tag (in place of content_tag) correctly.
openbrian Jun 30, 2020
4f57651
Merge branch 'master' into microcosms
openbrian Jul 2, 2020
8c652ed
Don't pollute the global namespace.
openbrian Jul 2, 2020
0dc53d8
Rename microcosm_member to microcosm_members.
openbrian Jul 2, 2020
a3fd3b7
Add tests for microcosm_members controller create.
openbrian Jul 2, 2020
00fb924
Add test for micocosm_member create failure.
openbrian Jul 3, 2020
6b8564b
Write more tests for microcosm_member.
openbrian Jul 15, 2020
a0c64a8
Improve error messages for microcosm controller and test. Use I18n, …
openbrian Jul 15, 2020
e7e14c5
Merge branch 'master' into microcosms
openbrian Jul 15, 2020
e293bf7
Get the create_when_save_fails test done using mocks.
openbrian Jul 17, 2020
7c7c4c5
Merge branch 'master' into microcosms
openbrian Jul 17, 2020
bc12fd8
Write up a test for microcosms_controller.update for when the update …
openbrian Jul 19, 2020
95082cd
Add tests for controllers when failures happen
openbrian Jul 19, 2020
086b142
No need for this controller.
openbrian Jul 19, 2020
c934f81
Use a block to control access to who can create and update events.
openbrian Jul 23, 2020
5d91eae
Merge branch 'master' into microcosms
openbrian Jul 23, 2020
3c773b1
Merge branch 'master' into microcosms
openbrian Jul 24, 2020
651d3a7
Fix a bad resolution to a merge conflict.
openbrian Jul 25, 2020
149b656
Write up a test for update microcosm as a non-organizer.
openbrian Jul 25, 2020
b56609a
Address brakeman findings. I added an exception for permit(:role) in…
openbrian Jul 25, 2020
f1fe638
Started testing event_attendance controller.
openbrian Jul 26, 2020
dcf6b78
When I uncommented code it accidentally re-indended stuff
openbrian Jul 26, 2020
c725919
When using constants instead of strings, use them everywhere.
openbrian Jul 27, 2020
f5dad9a
Finish writing tests for EventAttendancesController.
openbrian Jul 27, 2020
d6835a1
forgot to add structure.sql
openbrian Jul 27, 2020
a720b4a
Refactor show_members page to loop over organizers then members.
openbrian Jul 27, 2020
6525ccc
Refactor 2 step definitions into 1.
openbrian Jul 29, 2020
856a1f5
Allow user to leave a microcosm.
openbrian Jul 31, 2020
35aefdb
Merge branch 'master' into microcosms
openbrian Jul 31, 2020
ea8d3a9
Add ability to leavea microcosm. This is already covered in tests.
openbrian Aug 2, 2020
76568e5
Merge branch 'master' into microcosms
openbrian Aug 2, 2020
1b5604f
Now that :error is a normal flash type, we can use the shorthand vers…
openbrian Aug 7, 2020
8cba483
Merge branch 'master' into microcosms
openbrian Aug 7, 2020
c7283d0
Adapt to rubocop. In tests factor out some WET code into helper meth…
openbrian Aug 7, 2020
19d46cc
Handle plurals better
openbrian Aug 7, 2020
4da9655
Format these coords better.
openbrian Aug 8, 2020
6eeb82a
If the user is not signed in, provide a link to login before having t…
openbrian Aug 12, 2020
4dbe518
Merge branch 'master' into microcosms
openbrian Aug 12, 2020
94b378e
Get this test passing. Do no rely on .readonly!. Instead mock the s…
openbrian Aug 12, 2020
62e6447
Merge branch 'master' into microcosms
openbrian Jan 24, 2021
52b12a8
Coverals has been dropped.
openbrian Jan 24, 2021
d09c659
Warn if event was created in or updated to the past.
openbrian Jan 24, 2021
8cdbff8
Rubocop cleanups
openbrian Jan 24, 2021
48c5cfa
Rubocop fixes, forgot to add this file.
openbrian Jan 24, 2021
3f6e8e5
Normalize longitude input before using it.
openbrian Jan 25, 2021
2edcccc
Allow users to report a microcosm.
openbrian Jan 28, 2021
9f460fb
Only list microcosms with at least 2 members.
openbrian Jan 28, 2021
da6e7aa
Indent query to satisfy rubocop.
openbrian Jan 29, 2021
9a846e4
update test to reflect fact that only microcosms with more than 2 mem…
openbrian Feb 23, 2021
a1c173a
Merge remote-tracking branch 'upstream/master' into microcosms
openbrian Feb 23, 2021
6578740
Merge branch 'master' into microcosms
openbrian Apr 19, 2021
068eec4
Get tests working by not using :controller/:action in tests.
openbrian Apr 19, 2021
796ea40
Add a test for issues regarding a microcosm.
openbrian Apr 23, 2021
8d3120f
Add a test to cover reporting a microcosm.
openbrian Apr 25, 2021
78f8c9a
move dev message to bottom
openbrian Apr 25, 2021
215185b
Merge remote-tracking branch 'upstream/master' into microcosms
openbrian Apr 25, 2021
eb84c27
Always show the microcosms you belong to. Parameterize the "critical…
openbrian Apr 25, 2021
62abb5b
Convert event attendance intention to enum.
openbrian May 7, 2021
4f556e2
Include latest changes to structure.sql.
openbrian May 11, 2021
f756ce0
Merge remote-tracking branch 'upstream/master' into microcosms
openbrian May 11, 2021
c814558
"at least n members" in message.
openbrian Mar 27, 2022
20a6899
microcosm footer should be "fixed" position.
openbrian Mar 27, 2022
6875432
Make critical_mass a setting.
openbrian Mar 27, 2022
6acd050
Use degree symbol.
openbrian Mar 27, 2022
535bc0a
Support osm/rails at a sub-path.
openbrian Mar 27, 2022
1e35d93
When user is signed in, show *other* microcosms for "all" micricosms.
openbrian Mar 30, 2022
bbd9fb9
Show all members including organizers. And if you're the organizer, …
openbrian Mar 30, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/models/microcosm.rb
Expand Up @@ -44,7 +44,7 @@ def set_link(site, url)
end

def member?(user)
microcosm_members.where(:user_id => user.id).count.positive?
microcosm_members.members.where(:user_id => user.id).count.positive?
end

def organizer?(user)
Expand Down
4 changes: 2 additions & 2 deletions app/views/microcosms/show.html.erb
Expand Up @@ -45,7 +45,7 @@
</div>

<% if ! current_user || ! @microcosm.member?(current_user) %>
<%= form_with :scope => :microcosm_member, :url => microcosm_member_index_path do |form| %>
<%= form_with :scope => :microcosm_member, :url => microcosm_member_index_path, :local => true do |form| %>
<%= form.hidden_field(:microcosm_id, :value => @microcosm.id) %>
<%= form.hidden_field(:user_id, :value => current_user&.id) %>
<%= form.submit :value => t(".join.action") %>
Expand Down Expand Up @@ -97,7 +97,7 @@
<%= link_to t(".members"), members_of_microcosm_path(@microcosm) %>
</h2>
<div>
<% @microcosm.microcosm_members.each do |membership| %>
<% @microcosm.microcosm_members.members.each do |membership| %>
<%= user_card(membership.user).html_safe %>
<% end %>
</div>
Expand Down
127 changes: 124 additions & 3 deletions test/controllers/microcosms_controller_test.rb
@@ -1,7 +1,128 @@
require "test_helper"

class MicrocosmsControllerTest < ActionDispatch::IntegrationTest
# test "the truth" do
# assert true
# end
##
# test all routes which lead to this controller
def test_routes
assert_routing(
{ :path => "/microcosms", :method => :get },
{ :controller => "microcosms", :action => "index" }
)
assert_routing(
{ :path => "/microcosms/1", :method => :get },
{ :controller => "microcosms", :action => "show", :id => "1" }
)
assert_routing(
{ :path => "/microcosms/mdc", :method => :get },
{ :controller => "microcosms", :action => "show", :id => "mdc" }
)
assert_routing(
{ :path => "/microcosms/mdc/members", :method => :get },
{ :controller => "microcosms", :action => "show_members", :id => "mdc" }
)
assert_routing(
{ :path => "/microcosms/mdc/events", :method => :get },
{ :controller => "microcosms", :action => "show_events", :id => "mdc" }
)
assert_routing(
{ :path => "/microcosms/mdc/edit", :method => :get },
{ :controller => "microcosms", :action => "edit", :id => "mdc" }
)
assert_routing(
{ :path => "/microcosms/mdc", :method => :put },
{ :controller => "microcosms", :action => "update", :id => "mdc" }
)
assert_routing(
{ :path => "/microcosms/new", :method => :get },
{ :controller => "microcosms", :action => "new" }
)
assert_routing(
{ :path => "/microcosms", :method => :post },
{ :controller => "microcosms", :action => "create" }
)
end

def check_page_basics
assert_response :success
assert_no_missing_translations
end

def test_index_get
m = create(:microcosm)
get microcosms_path
check_page_basics
assert_template "index"
assert_match m.name, response.body
end

def test_show_get
m = create(:microcosm)
get microcosm_path(m)
check_page_basics
# assert_template("show")
assert_match m.name, response.body
assert_match m.description, response.body
end

def test_show_members_get
mm = create(:microcosm_member)
get members_of_microcosm_path(mm.microcosm)
check_page_basics
assert_match mm.user.display_name, response.body
end

def test_show_events_get
e = create(:event)
get events_of_microcosm_path(e.microcosm)
check_page_basics
assert_match e.title, response.body
end

def test_edit_get_no_session
m = create(:microcosm)
get edit_microcosm_path(m)
assert_response :redirect
assert_redirected_to :controller => :users, :action => :login, :referer => "/microcosms/#{m.slug}/edit"
end

def test_edit_get_is_not_member_is_not_organizer
m = create(:microcosm)
user = create(:user)
session_for(user)
get edit_microcosm_path(m)
follow_redirect!
assert_response :forbidden
end

def test_edit_get_is_member_not_organizer
mm = create(:microcosm_member)
session_for(mm.user)
get edit_microcosm_path(mm.microcosm)
follow_redirect!
assert_response :forbidden
end

def test_edit_get_is_organizer
mm = create(:microcosm_member, :organizer)
# We need to reload the object from PG because the floats in Ruby translate
# to double precision in PG and will actually loose 1 digit of precision. PG
# says 15, but it doesn't get that. Reload so values below are correct.
mm.reload
session_for(mm.user)
get edit_microcosm_path(mm.microcosm)
check_page_basics
assert_select "div#content", :count => 1 do
assert_select "form[action='/microcosms/#{mm.microcosm.slug}'][method=post]", :count => 1 do
assert_select "input#microcosm_location[name='microcosm[location]'][value='#{mm.microcosm.location}']", :count => 1
assert_select "input#microcosm_latitude[name='microcosm[latitude]'][value='#{mm.microcosm.latitude}']", :count => 1
assert_select "input#microcosm_longitude[name='microcosm[longitude]'][value='#{mm.microcosm.longitude}']", :count => 1
assert_select "input#microcosm_min_lat[name='microcosm[min_lat]'][value='#{mm.microcosm.min_lat}']", :count => 1
assert_select "input#microcosm_max_lat[name='microcosm[max_lat]'][value='#{mm.microcosm.max_lat}']", :count => 1
assert_select "input#microcosm_min_lon[name='microcosm[min_lon]'][value='#{mm.microcosm.min_lon}']", :count => 1
assert_select "input#microcosm_max_lon[name='microcosm[max_lon]'][value='#{mm.microcosm.max_lon}']", :count => 1
assert_select "textarea#microcosm_description[name='microcosm[description]']", :text => mm.microcosm.description, :count => 1
assert_select "input", :count => 11
end
end
end
end
16 changes: 9 additions & 7 deletions test/factories/events.rb
@@ -1,12 +1,14 @@
FactoryBot.define do
factory :event do
title { "MyString" }
moment { "2019-09-05T92:08:02" }
location { "Neverland" }
location_url { "https://example.org" }
description { "MyText" }
sequence(:title) { |n| "Title #{n}" }
moment { Time.now.utc }
sequence(:location) { |n| "Location #{n}" }
sequence(:location_url) { |n| "http://example.com/app/#{n}" }
sequence(:description) { |n| "Description #{n}" }
microcosm
latitude { 12.34 }
longitude { 56.78 }
latitude { rand(-90.0...90.0) }
longitude { rand(-180.0...180.0) }

# TODO: trait for event with attendees
end
end