mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-06 05:04:35 +08:00
Add tests for create new team page
Closes SCI-1620.
This commit is contained in:
parent
e078ae4f77
commit
ee96851951
1 changed files with 41 additions and 2 deletions
|
@ -6,8 +6,8 @@ describe ClientApi::Teams::TeamsController, type: :controller do
|
||||||
before do
|
before do
|
||||||
@user_one = User.first
|
@user_one = User.first
|
||||||
@user_two = FactoryGirl.create :user, email: 'sec_user@asdf.com'
|
@user_two = FactoryGirl.create :user, email: 'sec_user@asdf.com'
|
||||||
@team_one = FactoryGirl.create :team
|
@team_one = FactoryGirl.create :team, created_by: @user_one
|
||||||
@team_two = FactoryGirl.create :team, name: 'Team two'
|
@team_two = FactoryGirl.create :team, name: 'Team two', created_by: @user_two
|
||||||
FactoryGirl.create :user_team, team: @team_one, user: @user_one, role: 2
|
FactoryGirl.create :user_team, team: @team_one, user: @user_one, role: 2
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -19,6 +19,45 @@ describe ClientApi::Teams::TeamsController, type: :controller do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'POST #create' do
|
||||||
|
before do
|
||||||
|
@team_one.update_attribute(:name, 'My Team')
|
||||||
|
@team_one.update_attribute(:description, 'Lorem ipsum ipsum')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should return HTTP success response' do
|
||||||
|
post :create, params: { team: @team_one }, as: :json
|
||||||
|
expect(response).to have_http_status(:ok)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should return HTTP unprocessable_entity response if name too short' do
|
||||||
|
@team_one.update_attribute(
|
||||||
|
:name,
|
||||||
|
"#{'a' * (Constants::NAME_MIN_LENGTH - 1)}"
|
||||||
|
)
|
||||||
|
post :create, params: { team: @team_one }, as: :json
|
||||||
|
expect(response).to have_http_status(:unprocessable_entity)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should return HTTP unprocessable_entity response if name too long' do
|
||||||
|
@team_one.update_attribute(
|
||||||
|
:name,
|
||||||
|
"#{'a' * (Constants::NAME_MAX_LENGTH + 1)}"
|
||||||
|
)
|
||||||
|
post :create, params: { team: @team_one }, as: :json
|
||||||
|
expect(response).to have_http_status(:unprocessable_entity)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should return HTTP unprocessable_entity response if description too long' do
|
||||||
|
@team_one.update_attribute(
|
||||||
|
:description,
|
||||||
|
"#{'a' * (Constants::TEXT_MAX_LENGTH + 1)}"
|
||||||
|
)
|
||||||
|
post :create, params: { team: @team_one }, as: :json
|
||||||
|
expect(response).to have_http_status(:unprocessable_entity)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe 'POST #change_team' do
|
describe 'POST #change_team' do
|
||||||
it 'should return HTTP success response' do
|
it 'should return HTTP success response' do
|
||||||
FactoryGirl.create :user_team, team: @team_two, user: @user_one, role: 2
|
FactoryGirl.create :user_team, team: @team_two, user: @user_one, role: 2
|
||||||
|
|
Loading…
Add table
Reference in a new issue