Add functionality to re-release a movie
Opened this issue · 0 comments
marlabrizel commented
Add functionality that allows a movie to be re-released with an updated year.
Re-releasing a movie should:
- Create a new copy of the movie
- Set the copy's year to the year specified
- Redirect to the newly created movie
Use the following failing test cases to get started:
# test/integration/rereleases_test.rb
require 'test_helper'
class RereleasesTest < ActionDispatch::IntegrationTest
test "does not alter the original movie year" do
movie = create(:movie, year: "1985")
post "/movies/#{movie.id}/rereleases/", params: {
year: 2020,
}
first_release = Movie.find(movie.id)
assert_equal "1985", movie.year
end
test "creates a copy of the movie with the specified year" do
movie = create(:movie, year: "1985")
assert_difference(-> { Movie.where(title: movie.title).count }, 1) do
post "/movies/#{movie.id}/rereleases/", params: {
year: 2020,
}
end
rerelease = Movie.find_by(title: movie.title, year: 2020)
assert_equal "2020", rerelease.year
end
test "redirects to movie rerelease show page" do
movie = create(:movie, year: "1985")
post "/movies/#{movie.id}/rereleases/", params: {
year: 2020,
}
rerelease = Movie.find_by(title: movie.title, year: 2020)
assert_redirected_to movie_path(rerelease)
end
end