migrate from turbolinks to turbo

This commit is contained in:
2021-06-21 20:54:17 +02:00
parent 62464846a3
commit 87c1c67b5c
19 changed files with 367 additions and 40 deletions

View File

@@ -1,7 +1,130 @@
require 'rails_helper'
require 'rails_helper'
# This spec was generated by rspec-rails when you ran the scaffold generator.
# It demonstrates how one might use RSpec to test the controller code that
# was generated by Rails when you ran the scaffold generator.
#
# It assumes that the implementation code is generated by the rails scaffold
# generator. If you are using any extension libraries to generate different
# controller code, this generated spec may or may not pass.
#
# It only uses APIs available in rails and/or rspec-rails. There are a number
# of tools you can use to make these specs even more expressive, but we're
# sticking to rails and rspec-rails APIs to keep things simple and stable.
RSpec.describe "/rp_worlds", type: :request do
# RpWorld. As you add validations to RpWorld, be sure to
# adjust the attributes here as well.
let(:valid_attributes) {
skip("Add a hash of attributes valid for your model")
}
let(:invalid_attributes) {
skip("Add a hash of attributes invalid for your model")
}
RSpec.describe "RpWorlds", type: :request do
describe "GET /index" do
pending "add some examples (or delete) #{__FILE__}"
it "renders a successful response" do
RpWorld.create! valid_attributes
get rp_worlds_url
expect(response).to be_successful
end
end
describe "GET /show" do
it "renders a successful response" do
rp_world = RpWorld.create! valid_attributes
get rp_world_url(rp_world)
expect(response).to be_successful
end
end
describe "GET /new" do
it "renders a successful response" do
get new_rp_world_url
expect(response).to be_successful
end
end
describe "GET /edit" do
it "render a successful response" do
rp_world = RpWorld.create! valid_attributes
get edit_rp_world_url(rp_world)
expect(response).to be_successful
end
end
describe "POST /create" do
context "with valid parameters" do
it "creates a new RpWorld" do
expect {
post rp_worlds_url, params: { rp_world: valid_attributes }
}.to change(RpWorld, :count).by(1)
end
it "redirects to the created rp_world" do
post rp_worlds_url, params: { rp_world: valid_attributes }
expect(response).to redirect_to(rp_world_url(RpWorld.last))
end
end
context "with invalid parameters" do
it "does not create a new RpWorld" do
expect {
post rp_worlds_url, params: { rp_world: invalid_attributes }
}.to change(RpWorld, :count).by(0)
end
it "renders a successful response (i.e. to display the 'new' template)" do
post rp_worlds_url, params: { rp_world: invalid_attributes }
expect(response).to be_successful
end
end
end
describe "PATCH /update" do
context "with valid parameters" do
let(:new_attributes) {
skip("Add a hash of attributes valid for your model")
}
it "updates the requested rp_world" do
rp_world = RpWorld.create! valid_attributes
patch rp_world_url(rp_world), params: { rp_world: new_attributes }
rp_world.reload
skip("Add assertions for updated state")
end
it "redirects to the rp_world" do
rp_world = RpWorld.create! valid_attributes
patch rp_world_url(rp_world), params: { rp_world: new_attributes }
rp_world.reload
expect(response).to redirect_to(rp_world_url(rp_world))
end
end
context "with invalid parameters" do
it "renders a successful response (i.e. to display the 'edit' template)" do
rp_world = RpWorld.create! valid_attributes
patch rp_world_url(rp_world), params: { rp_world: invalid_attributes }
expect(response).to be_successful
end
end
end
describe "DELETE /destroy" do
it "destroys the requested rp_world" do
rp_world = RpWorld.create! valid_attributes
expect {
delete rp_world_url(rp_world)
}.to change(RpWorld, :count).by(-1)
end
it "redirects to the rp_worlds list" do
rp_world = RpWorld.create! valid_attributes
delete rp_world_url(rp_world)
expect(response).to redirect_to(rp_worlds_url)
end
end
end

View File

@@ -0,0 +1,38 @@
require "rails_helper"
RSpec.describe RpWorldsController, type: :routing do
describe "routing" do
it "routes to #index" do
expect(get: "/rp_worlds").to route_to("rp_worlds#index")
end
it "routes to #new" do
expect(get: "/rp_worlds/new").to route_to("rp_worlds#new")
end
it "routes to #show" do
expect(get: "/rp_worlds/1").to route_to("rp_worlds#show", id: "1")
end
it "routes to #edit" do
expect(get: "/rp_worlds/1/edit").to route_to("rp_worlds#edit", id: "1")
end
it "routes to #create" do
expect(post: "/rp_worlds").to route_to("rp_worlds#create")
end
it "routes to #update via PUT" do
expect(put: "/rp_worlds/1").to route_to("rp_worlds#update", id: "1")
end
it "routes to #update via PATCH" do
expect(patch: "/rp_worlds/1").to route_to("rp_worlds#update", id: "1")
end
it "routes to #destroy" do
expect(delete: "/rp_worlds/1").to route_to("rp_worlds#destroy", id: "1")
end
end
end

View File

@@ -0,0 +1,18 @@
require 'rails_helper'
RSpec.describe "rp_worlds/edit", type: :view do
before(:each) do
@rp_world = assign(:rp_world, RpWorld.create!(
name: "MyString"
))
end
it "renders the edit rp_world form" do
render
assert_select "form[action=?][method=?]", rp_world_path(@rp_world), "post" do
assert_select "input[name=?]", "rp_world[name]"
end
end
end

View File

@@ -0,0 +1,19 @@
require 'rails_helper'
RSpec.describe "rp_worlds/index", type: :view do
before(:each) do
assign(:rp_worlds, [
RpWorld.create!(
name: "Name"
),
RpWorld.create!(
name: "Name"
)
])
end
it "renders a list of rp_worlds" do
render
assert_select "tr>td", text: "Name".to_s, count: 2
end
end

View File

@@ -0,0 +1,18 @@
require 'rails_helper'
RSpec.describe "rp_worlds/new", type: :view do
before(:each) do
assign(:rp_world, RpWorld.new(
name: "MyString"
))
end
it "renders new rp_world form" do
render
assert_select "form[action=?][method=?]", rp_worlds_path, "post" do
assert_select "input[name=?]", "rp_world[name]"
end
end
end

View File

@@ -0,0 +1,14 @@
require 'rails_helper'
RSpec.describe "rp_worlds/show", type: :view do
before(:each) do
@rp_world = assign(:rp_world, RpWorld.create!(
name: "Name"
))
end
it "renders attributes in <p>" do
render
expect(rendered).to match(/Name/)
end
end