Skip to content

Commit

Permalink
Merge pull request #2249 from MushroomObserver/nimmo-break-up-obs-con…
Browse files Browse the repository at this point in the history
…troller-test

Break up `ObservationsControllerTest`
  • Loading branch information
nimmolo authored Jul 21, 2024
2 parents a2af77e + 5dd4eee commit 6840c56
Show file tree
Hide file tree
Showing 8 changed files with 3,410 additions and 3,368 deletions.
1,280 changes: 1,280 additions & 0 deletions test/controllers/observations_controller/observations_controller_create_test.rb

Large diffs are not rendered by default.

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
Loading

0 comments on commit 6840c56

Please sign in to comment.