first gallery version
This commit is contained in:
48
test/controllers/pictures_controller_test.rb
Normal file
48
test/controllers/pictures_controller_test.rb
Normal file
@ -0,0 +1,48 @@
|
||||
require "test_helper"
|
||||
|
||||
class PicturesControllerTest < ActionDispatch::IntegrationTest
|
||||
setup do
|
||||
@picture = pictures(:one)
|
||||
end
|
||||
|
||||
test "should get index" do
|
||||
get pictures_url
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get new" do
|
||||
get new_picture_url
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should create picture" do
|
||||
assert_difference("Picture.count") do
|
||||
post pictures_url, params: { picture: { member_id: @picture.member_id, picture: @picture.picture, text: @picture.text } }
|
||||
end
|
||||
|
||||
assert_redirected_to picture_url(Picture.last)
|
||||
end
|
||||
|
||||
test "should show picture" do
|
||||
get picture_url(@picture)
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get edit" do
|
||||
get edit_picture_url(@picture)
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should update picture" do
|
||||
patch picture_url(@picture), params: { picture: { member_id: @picture.member_id, picture: @picture.picture, text: @picture.text } }
|
||||
assert_redirected_to picture_url(@picture)
|
||||
end
|
||||
|
||||
test "should destroy picture" do
|
||||
assert_difference("Picture.count", -1) do
|
||||
delete picture_url(@picture)
|
||||
end
|
||||
|
||||
assert_redirected_to pictures_url
|
||||
end
|
||||
end
|
11
test/fixtures/pictures.yml
vendored
Normal file
11
test/fixtures/pictures.yml
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
picture: MyString
|
||||
text: MyString
|
||||
member: one
|
||||
|
||||
two:
|
||||
picture: MyString
|
||||
text: MyString
|
||||
member: two
|
7
test/models/picture_test.rb
Normal file
7
test/models/picture_test.rb
Normal file
@ -0,0 +1,7 @@
|
||||
require "test_helper"
|
||||
|
||||
class PictureTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
18
test/policies/picture_policy_test.rb
Normal file
18
test/policies/picture_policy_test.rb
Normal file
@ -0,0 +1,18 @@
|
||||
require 'test_helper'
|
||||
|
||||
class PicturePolicyTest < ActiveSupport::TestCase
|
||||
def test_scope
|
||||
end
|
||||
|
||||
def test_show
|
||||
end
|
||||
|
||||
def test_create
|
||||
end
|
||||
|
||||
def test_update
|
||||
end
|
||||
|
||||
def test_destroy
|
||||
end
|
||||
end
|
45
test/system/pictures_test.rb
Normal file
45
test/system/pictures_test.rb
Normal file
@ -0,0 +1,45 @@
|
||||
require "application_system_test_case"
|
||||
|
||||
class PicturesTest < ApplicationSystemTestCase
|
||||
setup do
|
||||
@picture = pictures(:one)
|
||||
end
|
||||
|
||||
test "visiting the index" do
|
||||
visit pictures_url
|
||||
assert_selector "h1", text: "Pictures"
|
||||
end
|
||||
|
||||
test "should create picture" do
|
||||
visit pictures_url
|
||||
click_on "New picture"
|
||||
|
||||
fill_in "Member", with: @picture.member_id
|
||||
fill_in "Picture", with: @picture.picture
|
||||
fill_in "Text", with: @picture.text
|
||||
click_on "Create Picture"
|
||||
|
||||
assert_text "Picture was successfully created"
|
||||
click_on "Back"
|
||||
end
|
||||
|
||||
test "should update Picture" do
|
||||
visit picture_url(@picture)
|
||||
click_on "Edit this picture", match: :first
|
||||
|
||||
fill_in "Member", with: @picture.member_id
|
||||
fill_in "Picture", with: @picture.picture
|
||||
fill_in "Text", with: @picture.text
|
||||
click_on "Update Picture"
|
||||
|
||||
assert_text "Picture was successfully updated"
|
||||
click_on "Back"
|
||||
end
|
||||
|
||||
test "should destroy Picture" do
|
||||
visit picture_url(@picture)
|
||||
click_on "Destroy this picture", match: :first
|
||||
|
||||
assert_text "Picture was successfully destroyed"
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user