Skip to content

Commit

Permalink
Add print tests
Browse files Browse the repository at this point in the history
  • Loading branch information
B-Rass committed Aug 27, 2024
1 parent 106f248 commit a9d4782
Show file tree
Hide file tree
Showing 6 changed files with 143 additions and 1 deletion.
1 change: 0 additions & 1 deletion app/views/frames/print.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,5 @@

<div class="container-fluid">
<%= render partial: "servers/room",
formats: :html,
locals: { room: @room, islets: @servers_per_frames, pdf: true, view_side: params[:view] } %>
</div>
30 changes: 30 additions & 0 deletions spec/requests/bays_request_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# frozen_string_literal: true

require "rails_helper"

RSpec.describe "Bays" do
let(:bay) { bays(:one) }

describe "GET #print" do
subject(:response) do
get print_bay_path(bay)

# NOTE: used to simplify usage and custom test done in final spec file.
@response # rubocop:disable RSpec/InstanceVariable
end

include_context "with authenticated user"

context "with not found bay" do
let(:bay) { Bay.new(id: SecureRandom.uuid) }

it { expect { response }.to raise_error(ActiveRecord::RecordNotFound) }
end

context "with existing bay" do
it { expect(response).to have_http_status(:success) }
it { expect(response).to render_template(:print) }
it { expect(response).to render_template("layouts/pdf") }
end
end
end
30 changes: 30 additions & 0 deletions spec/requests/frames_request_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# frozen_string_literal: true

require "rails_helper"

RSpec.describe "Frames" do
let(:frame) { frames(:one) }

describe "GET #print" do
subject(:response) do
get print_frame_path(frame)

# NOTE: used to simplify usage and custom test done in final spec file.
@response # rubocop:disable RSpec/InstanceVariable
end

include_context "with authenticated user"

context "with not found frame" do
let(:frame) { Frame.new(id: SecureRandom.uuid) }

it { expect { response }.to raise_error(ActiveRecord::RecordNotFound) }
end

context "with existing frame" do
it { expect(response).to have_http_status(:success) }
it { expect(response).to render_template(:print) }
it { expect(response).to render_template("layouts/pdf") }
end
end
end
23 changes: 23 additions & 0 deletions spec/requests/islets_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -182,4 +182,27 @@
it { expect(response).to redirect_to(islets_path) }
end
end

describe "GET #print" do
subject(:response) do
get print_islet_path(islet)

# NOTE: used to simplify usage and custom test done in final spec file.
@response # rubocop:disable RSpec/InstanceVariable
end

include_context "with authenticated user"

context "with not found islet" do
let(:islet) { Islet.new(id: SecureRandom.uuid) }

it { expect { response }.to raise_error(ActiveRecord::RecordNotFound) }
end

context "with existing islet" do
it { expect(response).to have_http_status(:success) }
it { expect(response).to render_template(:print) }
it { expect(response).to render_template("layouts/pdf") }
end
end
end
30 changes: 30 additions & 0 deletions spec/requests/moves_request_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# frozen_string_literal: true

require "rails_helper"

RSpec.describe "Moves" do
let(:move) { moves(:one) }

describe "GET #print" do
subject(:response) do
get print_moves_path(move.frame_id)

# NOTE: used to simplify usage and custom test done in final spec file.
@response # rubocop:disable RSpec/InstanceVariable
end

include_context "with authenticated user"

context "with not found frame" do
before { move.frame_id = SecureRandom.uuid }

it { expect { response }.to raise_error(ActiveRecord::RecordNotFound) }
end

context "with existing move" do
it { expect(response).to have_http_status(:success) }
it { expect(response).to render_template(:print) }
it { expect(response).to render_template("layouts/pdf") }
end
end
end
30 changes: 30 additions & 0 deletions spec/requests/rooms_request_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# frozen_string_literal: true

require "rails_helper"

RSpec.describe "Rooms" do
let(:room) { rooms(:one) }

describe "GET #print" do
subject(:response) do
get print_room_path(room)

# NOTE: used to simplify usage and custom test done in final spec file.
@response # rubocop:disable RSpec/InstanceVariable
end

include_context "with authenticated user"

context "with not found room" do
let(:room) { Room.new(id: SecureRandom.uuid) }

it { expect { response }.to raise_error(ActiveRecord::RecordNotFound) }
end

context "with existing room" do
it { expect(response).to have_http_status(:success) }
it { expect(response).to render_template(:print) }
it { expect(response).to render_template("layouts/pdf") }
end
end
end

0 comments on commit a9d4782

Please sign in to comment.