-
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.
Merge pull request #126 from npauzenga/tasks/join-table-acceptance-specs
Tasks/join table acceptance specs
- Loading branch information
Showing
11 changed files
with
95 additions
and
32 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,17 @@ | ||
class GameNightAttendancesController < AuthenticationController | ||
# POST /game_nights/:game_night_id/game_night_attendences | ||
def create | ||
result = CreateGameNightAttendance.call(user_id: current_user.id, | ||
game_night_id: params[:id]) | ||
result = CreateGameNightAttendance.call(interactor_params) | ||
if result.success? | ||
head :no_content | ||
else | ||
render json: result.errors, status: :internal_server_error | ||
end | ||
end | ||
|
||
private | ||
|
||
def interactor_params | ||
{ user_id: current_user.id, game_night_id: params[:game_night_id] } | ||
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
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
require "rspec_api_documentation/dsl" | ||
|
||
RSpec.resource "UserGameNightAttendance" do | ||
let(:authenticated_user) do | ||
create(:confirmed_user) | ||
end | ||
|
||
let(:auth_token) do | ||
Knock::AuthToken.new(payload: { sub: authenticated_user.id }).token | ||
end | ||
|
||
shared_context "user_game_night_attendance parameters" do | ||
parameter "game_night_id", <<-DESC, scope: :game_night, required: true | ||
The unique id of the game_night. | ||
DESC | ||
end | ||
|
||
post "/game_nights/:game_night_id/game_night_attendances" do | ||
include_context "user_game_night_attendance parameters" | ||
|
||
let!(:game_night) { create(:game_night) } | ||
let(:game_night_id) { game_night.id } | ||
|
||
header "Authorization", :auth_token | ||
|
||
example_request "POST /game_nights/:game_night_id/game_night_attendances" do | ||
expect(status).to eq 204 | ||
|
||
expect(authenticated_user.game_nights.first.name).to eq(game_night.name) | ||
|
||
expect(game_night.users.first).to eq authenticated_user | ||
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
require "rspec_api_documentation/dsl" | ||
|
||
RSpec.resource "UserGroupMembership" do | ||
let(:authenticated_user) do | ||
create(:confirmed_user) | ||
end | ||
|
||
let(:auth_token) do | ||
Knock::AuthToken.new(payload: { sub: authenticated_user.id }).token | ||
end | ||
|
||
shared_context "user_group_membership parameters" do | ||
parameter "group_id", <<-DESC, scope: :group, required: true | ||
The unique id of the group to which the game_night belongs. | ||
DESC | ||
end | ||
|
||
post "/groups/:group_id/group_memberships" do | ||
include_context "user_group_membership parameters" | ||
|
||
let!(:group) { create(:group) } | ||
let(:group_id) { group.id } | ||
|
||
header "Authorization", :auth_token | ||
|
||
example_request "POST /groups/:group_id/group_memberships" do | ||
expect(status).to eq 204 | ||
|
||
expect(authenticated_user.groups.first.name).to eq(group.name) | ||
|
||
expect(group.users.first).to eq authenticated_user | ||
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
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,8 +1,8 @@ | ||
FactoryGirl.define do | ||
factory :game_night do | ||
name Faker::Hipster.words(2) | ||
name Faker::Team.name | ||
time { rand(7).days.from_now.to_date } | ||
location_name Faker::Hipster.words(2) | ||
location_name Faker::Company.name | ||
location_address Faker::Address.street_name | ||
end | ||
end |