@@ -33,15 +33,25 @@ class ScaffoldControllerGeneratorTest < Rails::Generators::TestCase
33
33
assert_match %r{@post\. save} , m
34
34
assert_match %r{format\. html \{ redirect_to @post, notice: "Post was successfully created\. " \} } , m
35
35
assert_match %r{format\. json \{ render :show, status: :created, location: @post \} } , m
36
- assert_match %r{format\. html \{ render :new, status: :unprocessable_entity \} } , m
37
- assert_match %r{format\. json \{ render json: @post\. errors, status: :unprocessable_entity \} } , m
36
+ if Gem ::Version . new ( Rack ::RELEASE ) < Gem ::Version . new ( "3.1" )
37
+ assert_match %r{format\. html \{ render :new, status: :unprocessable_entity \} } , m
38
+ assert_match %r{format\. json \{ render json: @post\. errors, status: :unprocessable_entity \} } , m
39
+ else
40
+ assert_match %r{format\. html \{ render :new, status: :unprocessable_content \} } , m
41
+ assert_match %r{format\. json \{ render json: @post\. errors, status: :unprocessable_content \} } , m
42
+ end
38
43
end
39
44
40
45
assert_instance_method :update , content do |m |
41
46
assert_match %r{format\. html \{ redirect_to @post, notice: "Post was successfully updated\. ", status: :see_other \} } , m
42
47
assert_match %r{format\. json \{ render :show, status: :ok, location: @post \} } , m
43
- assert_match %r{format\. html \{ render :edit, status: :unprocessable_entity \} } , m
44
- assert_match %r{format\. json \{ render json: @post.errors, status: :unprocessable_entity \} } , m
48
+ if Gem ::Version . new ( Rack ::RELEASE ) < Gem ::Version . new ( "3.1" )
49
+ assert_match %r{format\. html \{ render :edit, status: :unprocessable_entity \} } , m
50
+ assert_match %r{format\. json \{ render json: @post.errors, status: :unprocessable_entity \} } , m
51
+ else
52
+ assert_match %r{format\. html \{ render :edit, status: :unprocessable_content \} } , m
53
+ assert_match %r{format\. json \{ render json: @post.errors, status: :unprocessable_content \} } , m
54
+ end
45
55
end
46
56
47
57
assert_instance_method :destroy , content do |m |
0 commit comments