Skip to content

Commit

Permalink
[ci] Migration of project controller tests: Users action
Browse files Browse the repository at this point in the history
  • Loading branch information
Moises Deniz Aleman committed Apr 4, 2016
1 parent e092146 commit 6682718
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions src/api/spec/controllers/webui/project_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
describe 'GET #index' do
context 'showing all projects' do
before do
create(:confirmed_user, login: 'moi')
create(:project)
create(:project, name: 'home:moi')
create(:project, name: 'AnotherProject')
get :index, { show_all: true}
end

Expand All @@ -34,8 +34,8 @@

context 'showing not home projects' do
before do
create(:confirmed_user, login: 'moi')
create(:project)
create(:project, name: 'home:moi')
create(:project, name: 'AnotherProject')
get :index, { show_all: false}
end

Expand Down Expand Up @@ -68,8 +68,6 @@
@json_response = JSON.parse(response.body)
end

it { expect(@json_response).to be_a(Array) }
it { expect(@json_response.length).to eq(3) }
it { expect(@json_response).to contain_exactly('Apache', 'Apache2', 'openSUSE') }
it { expect(@json_response).not_to include('ApacheMI') }
end
Expand All @@ -80,8 +78,6 @@
@json_response = JSON.parse(response.body)
end

it { expect(@json_response).to be_a(Array)}
it { expect(@json_response.length).to eq(2) }
it { expect(@json_response).to contain_exactly('Apache', 'Apache2') }
it { expect(@json_response).not_to include('ApacheMI') }
it { expect(@json_response).not_to include('openSUSE') }
Expand All @@ -96,7 +92,6 @@
@json_response = JSON.parse(response.body)
end

it { expect(@json_response).to be_a(Array) }
it { expect(@json_response).to contain_exactly('ApacheMI') }
it { expect(@json_response).not_to include('Apache') }
end
Expand All @@ -116,8 +111,6 @@
@json_response = JSON.parse(response.body)
end

it { expect(@json_response).to be_a(Array) }
it { expect(@json_response.length).to eq(2) }
it { expect(@json_response).to contain_exactly('Apache_Package', 'Apache2_Package') }
it { expect(@json_response).not_to include('Apache_Package_Another_Project') }
end
Expand All @@ -128,8 +121,6 @@
@json_response = JSON.parse(response.body)
end

it { expect(@json_response).to be_a(Array)}
it { expect(@json_response.length).to eq(1) }
it { expect(@json_response).to contain_exactly('Apache2_Package') }
it { expect(@json_response).not_to include('Apache_Package') }
it { expect(@json_response).not_to include('Apache_Package_Another_Project') }
Expand All @@ -144,12 +135,25 @@
@json_response = JSON.parse(response.body)
end

it { expect(@json_response).to be_a(Array) }
it { expect(@json_response.length).to eq(5) }
it { expect(@json_response).to match_array(@repositories.map {|r| r.name }) }
end

describe 'GET #users' do
before do
@project = create(:project)
create(:relationship_project_user, project: @project, user: create(:confirmed_user))
create(:relationship_project_user, project: @project, user: create(:confirmed_user))
create(:relationship_project_group, project: @project, group: create(:group))

another_project = create(:project)
create(:relationship_project_user, project: another_project, user: create(:confirmed_user))
create(:relationship_project_group, project: another_project, group: create(:group))
get :users, project: @project
end

it { expect(assigns(:users)).to match_array(@project.users) }
it { expect(assigns(:groups)).to match_array(@project.groups) }
it { expect(assigns(:roles)).to match_array(Role.local_roles) }
end

describe 'GET #subprojects' do
Expand Down

0 comments on commit 6682718

Please sign in to comment.