forked from hmlON/room538
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add index action to rooms controller
- Loading branch information
Showing
9 changed files
with
59 additions
and
7 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
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,3 +1,5 @@ | ||
h1 Welcome to room538 | ||
|
||
= link_to 'Create new room', new_room_path | ||
p | ||
= link_to 'Create new room', new_room_path | ||
p | ||
= link_to 'All rooms', rooms_path |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.room | ||
h3 = room.name | ||
- room.users.each do |user| | ||
p = user.name |
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 @@ | ||
h1 Rooms#index | ||
p Find me in app/views/rooms/index.html.slim | ||
h1 All rooms | ||
= render @rooms |
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
RSpec.describe RoomsController, type: :controller do | ||
include Devise::Test::ControllerHelpers | ||
|
||
context 'when user signed in' do | ||
let(:user) { create(:user) } | ||
before(:each) do | ||
sign_in user | ||
end | ||
|
||
describe 'GET #index' do | ||
it 'returns http success' do | ||
create_list(:room, 5, users: create_list(:user, 4)) | ||
|
||
get :index | ||
|
||
expect(response).to have_http_status(:success) | ||
expect(response).to render_template(:index) | ||
expect(assigns(:rooms).length).to eq 5 | ||
end | ||
end | ||
end | ||
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,5 +1,5 @@ | ||
FactoryGirl.define do | ||
factory :room do | ||
name { Faker::Hipster.sentence(2) } | ||
name { Faker::Hipster.word } | ||
end | ||
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,14 +1,30 @@ | ||
RSpec.feature 'Rooms' do | ||
let(:user) { create(:user) } | ||
|
||
scenario 'User creates new room' do | ||
background do | ||
sign_in user | ||
visit root_path | ||
end | ||
|
||
scenario 'User creates new room' do | ||
click_link 'Create new room' | ||
|
||
fill_in 'Name', with: 'My room' | ||
click_on 'Create room' | ||
|
||
expect(page).to have_content 'You successfully created new room "My room"' | ||
end | ||
|
||
scenario 'User looks at all rooms' do | ||
rooms = create_list(:room, 3, users: create_list(:user, 3)) | ||
|
||
click_link 'All rooms' | ||
|
||
rooms.each do |room| | ||
expect(page).to have_content room.name | ||
room.users.each do |user| | ||
expect(page).to have_content user.name | ||
end | ||
end | ||
end | ||
end |