-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
104 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
# frozen_string_literal: true | ||
|
||
module RequestsHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
class Request < ApplicationRecord | ||
enum status: %i[pending accepted rejected] | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
json.extract! request, :id, :operating_system, :ram_mb, :cpu_cores, :software, :comment, :accepted, :created_at, :updated_at | ||
json.extract! request, :id, :operating_system, :ram_mb, :cpu_cores, :software, :comment, :rejection_information, :status, :created_at, :updated_at | ||
json.url request_url(request, format: :json) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,53 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe 'requests/show', type: :view do | ||
before(:each) do | ||
@request = assign(:request, Request.create!( | ||
operating_system: 'Operating System', | ||
ram_mb: 2, | ||
cpu_cores: 3, | ||
software: 'Software', | ||
comment: 'Comment', | ||
accepted: false | ||
)) | ||
RSpec.describe 'requests/show', type: :feature do | ||
context 'when request status is pending' do | ||
let(:request) { FactoryBot.create :request } | ||
|
||
it 'renders attributes in <p>' do | ||
visit request_path(request) | ||
|
||
expect(page).to have_text(request.operating_system) | ||
expect(page).to have_text(request.ram_mb) | ||
expect(page).to have_text(request.cpu_cores) | ||
expect(page).to have_text(request.software) | ||
expect(page).to have_text(request.status) | ||
expect(page).to have_text(request.comment) | ||
end | ||
|
||
it 'has accept button' do | ||
visit request_path(request) | ||
|
||
click_button('Accept') | ||
request.reload | ||
expect(request.status).to eq('accepted') | ||
end | ||
|
||
it 'has reject button' do | ||
visit request_path(request) | ||
|
||
click_button('Reject') | ||
request.reload | ||
expect(request.status).to eq('rejected') | ||
end | ||
|
||
it 'has rejection_information input field' do | ||
visit request_path(request) | ||
|
||
page.fill_in 'request[rejection_information]', with: 'Info' | ||
click_button('Reject') | ||
request.reload | ||
expect(request.rejection_information).to eq('Info') | ||
end | ||
end | ||
|
||
it 'renders attributes in <p>' do | ||
render | ||
expect(rendered).to match(/Operating System/) | ||
expect(rendered).to match(/2/) | ||
expect(rendered).to match(/3/) | ||
expect(rendered).to match(/Software/) | ||
expect(rendered).to match(/Comment/) | ||
expect(rendered).to match(/false/) | ||
context 'when request is rejected' do | ||
let(:rejected_request) { FactoryBot.create :rejected_request } | ||
|
||
it 'Has rejection Information field' do | ||
visit request_path(rejected_request) | ||
|
||
expect(page).to have_text(rejected_request.rejection_information) | ||
end | ||
end | ||
end |