-
Notifications
You must be signed in to change notification settings - Fork 26
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 #2249 from MushroomObserver/nimmo-break-up-obs-con…
…troller-test Break up `ObservationsControllerTest`
- Loading branch information
Showing
8 changed files
with
3,410 additions
and
3,368 deletions.
There are no files selected for viewing
1,280 changes: 1,280 additions & 0 deletions
1,280
test/controllers/observations_controller/observations_controller_create_test.rb
Large diffs are not rendered by default.
Oops, something went wrong.
62 changes: 62 additions & 0 deletions
62
test/controllers/observations_controller/observations_controller_destroy_test.rb
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,62 @@ | ||
# frozen_string_literal: true | ||
|
||
require("test_helper") | ||
|
||
class ObservationsControllerDestroyTest < FunctionalTestCase | ||
tests ObservationsController | ||
|
||
############################################################################## | ||
|
||
# -------------------- Destroy ---------------------------------------- # | ||
|
||
def test_destroy_observation | ||
assert(obs = observations(:minimal_unknown_obs)) | ||
id = obs.id | ||
params = { id: id } | ||
assert_equal("mary", obs.user.login) | ||
requires_user(:destroy, | ||
[{ action: :show }], | ||
params, "mary") | ||
assert_redirected_to(action: :index) | ||
assert_raises(ActiveRecord::RecordNotFound) do | ||
obs = Observation.find(id) | ||
end | ||
end | ||
|
||
def test_original_filename_visibility | ||
login("mary") | ||
obs_id = observations(:agaricus_campestris_obs).id | ||
|
||
rolf.keep_filenames = "toss" | ||
rolf.save | ||
get(:show, params: { id: obs_id }) | ||
assert_false(@response.body.include?("áč€εиts")) | ||
|
||
rolf.keep_filenames = "keep_but_hide" | ||
rolf.save | ||
get(:show, params: { id: obs_id }) | ||
assert_false(@response.body.include?("áč€εиts")) | ||
|
||
rolf.keep_filenames = "keep_and_show" | ||
rolf.save | ||
get(:show, params: { id: obs_id }) | ||
assert_true(@response.body.include?("áč€εиts")) | ||
|
||
login("rolf") # owner | ||
|
||
rolf.keep_filenames = "toss" | ||
rolf.save | ||
get(:show, params: { id: obs_id }) | ||
assert_true(@response.body.include?("áč€εиts")) | ||
|
||
rolf.keep_filenames = "keep_but_hide" | ||
rolf.save | ||
get(:show, params: { id: obs_id }) | ||
assert_true(@response.body.include?("áč€εиts")) | ||
|
||
rolf.keep_filenames = "keep_and_show" | ||
rolf.save | ||
get(:show, params: { id: obs_id }) | ||
assert_true(@response.body.include?("áč€εиts")) | ||
end | ||
end |
Oops, something went wrong.