ensl.org/spec/controllers/api/v1/teams_controller_spec.rb

36 lines
1,010 B
Ruby
Raw Normal View History

2020-03-23 02:10:31 +00:00
require "rails_helper"
2016-04-16 23:05:18 +00:00
describe Api::V1::TeamsController do
before do
request.accept = "application/json"
end
describe "#show" do
before(:each) do
@founder = create :user
@team_member = create :user
@ex_team_member = create :user
@team = create :team, founder: @founder
Teamer.create user: @team_member, team: @team, rank: Teamer::RANK_MEMBER
Teamer.create user: @ex_team_member, team: @team, rank: Teamer::RANK_REMOVED
end
it "returns team data" do
2020-03-23 02:22:12 +00:00
get :show, params: { id: @team.id }
expect(response).to have_http_status(:success)
2016-04-16 23:05:18 +00:00
expect(json["id"]).to eq(@team.id)
expect(json["name"]).to eq(@team.name)
json["members"].each do |member|
expect(@team.teamers.active.map(&:user_id)).to include(member["id"])
end
end
it "returns 404 if team not found" do
expect {
2020-03-23 02:22:12 +00:00
get :show, params: { id: Team.last.id + 1 }
2016-04-16 23:05:18 +00:00
}.to raise_error(ActionController::RoutingError)
end
end
end