Compare commits

...

3 Commits

Author SHA1 Message Date
Christophe Bliard 7865fcd784
Stop using respond_with helper from shoulda 2 years ago
Christophe Bliard 13bcd84eab
Use rspec-rails helpers for routing tests 2 years ago
Christophe Bliard 7218f9bde7
Remove should-matchers gem 2 years ago
  1. 2
      Gemfile
  2. 5
      Gemfile.lock
  3. 10
      modules/boards/spec/routing/boards_routing_spec.rb
  4. 27
      modules/team_planner/spec/routing/team_planner_routing_spec.rb
  5. 8
      spec/controllers/account_controller_spec.rb
  6. 36
      spec/controllers/auth_sources_controller_spec.rb
  7. 2
      spec/controllers/ldap_auth_sources_controller_spec.rb
  8. 2
      spec/controllers/work_packages_controller_spec.rb
  9. 1
      spec/rails_helper.rb
  10. 62
      spec/routing/enumerations_spec.rb
  11. 6
      spec/routing/errors_routing_spec.rb
  12. 75
      spec/routing/forums_routing_spec.rb
  13. 84
      spec/routing/groups_spec.rb
  14. 31
      spec/routing/members_spec.rb
  15. 58
      spec/routing/messages_spec.rb
  16. 16
      spec/routing/news_comments_spec.rb
  17. 61
      spec/routing/news_spec.rb
  18. 80
      spec/routing/roles_spec.rb
  19. 66
      spec/routing/users_routing_spec.rb
  20. 65
      spec/routing/versions_spec.rb
  21. 204
      spec/routing/wiki_routing_spec.rb
  22. 7
      spec/support/shared/shoulda_matcher.rb

@ -210,7 +210,6 @@ gem "appsignal", "~> 3.0", require: false
group :test do
gem 'launchy', '~> 2.5.0'
gem 'rack-test', '~> 2.0.0'
gem 'shoulda-context', '~> 2.0'
# Test prof provides factories from code
# and other niceties
@ -248,7 +247,6 @@ group :test do
gem 'equivalent-xml', '~> 0.6'
gem 'json_spec', '~> 1.1.4'
gem 'shoulda-matchers', '~> 5.0', require: nil
gem 'parallel_tests', '~> 3.1'
end

@ -911,9 +911,6 @@ GEM
sentry-ruby (~> 5.5.0)
sentry-ruby (5.5.0)
concurrent-ruby (~> 1.0, >= 1.0.2)
shoulda-context (2.0.0)
shoulda-matchers (5.2.0)
activesupport (>= 5.2.0)
spreadsheet (1.3.0)
ruby-ole
spring (4.1.0)
@ -1151,8 +1148,6 @@ DEPENDENCIES
sentry-delayed_job (~> 5.5.0)
sentry-rails (~> 5.5.0)
sentry-ruby (~> 5.5.0)
shoulda-context (~> 2.0)
shoulda-matchers (~> 5.0)
spring
spring-commands-rspec
sprockets (~> 3.7.2)

@ -30,14 +30,12 @@ require 'spec_helper'
describe 'Boards routing', type: :routing do
it {
expect(subject)
.to route(:get, '/projects/foobar/boards/state')
.to(controller: 'boards/boards', action: 'index', project_id: 'foobar', state: 'state')
expect(get('/projects/foobar/boards/state'))
.to route_to(controller: 'boards/boards', action: 'index', project_id: 'foobar', state: 'state')
}
it {
expect(subject)
.to route(:get, '/boards/state')
.to(controller: 'boards/boards', action: 'index', state: 'state')
expect(get('/boards/state'))
.to route_to(controller: 'boards/boards', action: 'index', state: 'state')
}
end

@ -30,33 +30,28 @@ require 'spec_helper'
describe 'Team planner routing', type: :routing do
it 'routes to team_planner#index' do
expect(subject)
.to route(:get, '/projects/foobar/team_planners')
.to(controller: 'team_planner/team_planner', action: :index, project_id: 'foobar')
expect(get('/projects/foobar/team_planners'))
.to route_to(controller: 'team_planner/team_planner', action: "index", project_id: 'foobar')
end
it 'routes to team_planner#show' do
expect(subject)
.to route(:get, '/projects/foobar/team_planners/1234')
.to(controller: 'team_planner/team_planner', action: :show, project_id: 'foobar', id: '1234')
expect(get('/projects/foobar/team_planners/1234'))
.to route_to(controller: 'team_planner/team_planner', action: "show", project_id: 'foobar', id: '1234')
end
it 'routes to team_planner#new' do
expect(subject)
.to route(:get, '/projects/foobar/team_planners/new')
.to(controller: 'team_planner/team_planner', action: :show, project_id: 'foobar')
expect(get('/projects/foobar/team_planners/new'))
.to route_to(controller: 'team_planner/team_planner', action: "show", project_id: 'foobar')
end
it 'routes to team_planner#show with state' do
expect(subject)
.to route(:get, '/projects/foobar/team_planners/1234/details/555')
.to(controller: 'team_planner/team_planner', action: :show, project_id: 'foobar', id: '1234',
state: 'details/555')
expect(get('/projects/foobar/team_planners/1234/details/555'))
.to route_to(controller: 'team_planner/team_planner', action: "show", project_id: 'foobar', id: '1234',
state: 'details/555')
end
it 'routes to team_planner#destroy' do
expect(subject)
.to route(:delete, '/projects/foobar/team_planners/1234')
.to(controller: 'team_planner/team_planner', action: :destroy, project_id: 'foobar', id: '1234')
expect(delete('/projects/foobar/team_planners/1234'))
.to route_to(controller: 'team_planner/team_planner', action: "destroy", project_id: 'foobar', id: '1234')
end
end

@ -561,7 +561,7 @@ describe AccountController,
end
it 'is successful' do
expect(subject).to respond_with :success
expect(response).to have_http_status :ok
expect(response).to render_template :register
expect(assigns[:user]).not_to be_nil
expect(assigns[:user].notification_settings.size).to eq(1)
@ -601,7 +601,7 @@ describe AccountController,
end
it 'is successful' do
expect(subject).to respond_with :success
expect(response).to have_http_status :ok
expect(response).to render_template :register
expect(assigns[:user]).not_to be_nil
end
@ -634,7 +634,7 @@ describe AccountController,
end
it 'redirects to the expected path' do
expect(subject).to respond_with :redirect
expect(response).to have_http_status :redirect
expect(assigns[:user]).not_to be_nil
expect(subject).to redirect_to(redirect_to_path)
expect(User.where(login: 'register').last).not_to be_nil
@ -870,7 +870,7 @@ describe AccountController,
end
it 'registers the user on-the-fly' do
expect(subject).to respond_with :success
expect(response).to have_http_status :ok
expect(response).to render_template :register
post :register,

@ -42,8 +42,8 @@ describe AuthSourcesController, type: :controller do
get :index
end
it { expect(assigns(:auth_source)).to eq @auth_source }
it { is_expected.to respond_with :success }
it { expect(assigns(:auth_source)).to be_nil }
it { expect(response).to have_http_status :ok }
it { is_expected.to render_template :index }
end
@ -53,7 +53,7 @@ describe AuthSourcesController, type: :controller do
end
it { expect(assigns(:auth_source)).not_to be_nil }
it { is_expected.to respond_with :success }
it { expect(response).to have_http_status :ok }
it { is_expected.to render_template :new }
it 'initializes a new AuthSource' do
@ -67,9 +67,9 @@ describe AuthSourcesController, type: :controller do
post :create, params: { auth_source: { name: 'Test' } }
end
it { is_expected.to respond_with :redirect }
it { expect(response).to have_http_status :redirect }
it { is_expected.to redirect_to auth_sources_path }
it { is_expected.to set_flash.to /success/i }
it { expect(flash[:notice]).to match(/success/i) }
end
describe 'edit' do
@ -79,7 +79,7 @@ describe AuthSourcesController, type: :controller do
end
it { expect(assigns(:auth_source)).to eq @auth_source }
it { is_expected.to respond_with :success }
it { expect(response).to have_http_status :ok }
it { is_expected.to render_template :edit }
end
@ -89,9 +89,9 @@ describe AuthSourcesController, type: :controller do
post :update, params: { id: @auth_source.id, auth_source: { name: 'TestUpdate' } }
end
it { is_expected.to respond_with :redirect }
it { expect(response).to have_http_status :redirect }
it { is_expected.to redirect_to auth_sources_path }
it { is_expected.to set_flash.to /update/i }
it { expect(flash[:notice]).to match(/update/i) }
end
describe 'destroy' do
@ -104,9 +104,9 @@ describe AuthSourcesController, type: :controller do
post :destroy, params: { id: @auth_source.id }
end
it { is_expected.to respond_with :redirect }
it { expect(response).to have_http_status :redirect }
it { is_expected.to redirect_to auth_sources_path }
it { is_expected.to set_flash.to /deletion/i }
it { expect(flash[:notice]).to match(/deletion/) }
end
context 'with users' do
@ -115,9 +115,9 @@ describe AuthSourcesController, type: :controller do
post :destroy, params: { id: @auth_source.id }
end
it { is_expected.to respond_with :redirect }
it { expect(response).to have_http_status :redirect }
it 'doesn not destroy the AuthSource' do
it 'does not destroy the AuthSource' do
expect(AuthSource.find(@auth_source.id)).not_to be_nil
end
end
@ -131,37 +131,37 @@ describe AuthSourcesController, type: :controller do
it 'cannot find index' do
get :index
expect(response.status).to eq 404
expect(response).to have_http_status :not_found
end
it 'cannot find new' do
get :new
expect(response.status).to eq 404
expect(response).to have_http_status :not_found
end
it 'cannot find create' do
post :create, params: { auth_source: { name: 'Test' } }
expect(response.status).to eq 404
expect(response).to have_http_status :not_found
end
it 'cannot find edit' do
get :edit, params: { id: 42 }
expect(response.status).to eq 404
expect(response).to have_http_status :not_found
end
it 'cannot find update' do
post :update, params: { id: 42, auth_source: { name: 'TestUpdate' } }
expect(response.status).to eq 404
expect(response).to have_http_status :not_found
end
it 'cannot find destroy' do
post :destroy, params: { id: 42 }
expect(response.status).to eq 404
expect(response).to have_http_status :not_found
end
end
end

@ -41,7 +41,7 @@ describe LdapAuthSourcesController, type: :controller do
end
it { expect(assigns(:auth_source)).not_to be_nil }
it { is_expected.to respond_with :success }
it { expect(response).to have_http_status :success }
it { is_expected.to render_template :new }
it 'initializes a new AuthSource' do

@ -261,7 +261,7 @@ describe WorkPackagesController, type: :controller do
get('index', params: { project_id: 'project_that_doesnt_exist' })
end
it { is_expected.to respond_with :not_found }
it { expect(response).to have_http_status :not_found }
end
describe 'show.html' do

@ -29,7 +29,6 @@ ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../config/environment', __dir__)
require 'factory_bot_rails'
require 'rspec/rails'
require 'shoulda/matchers'
# Require test_prof helpers for better performance around factories/specs
# see https://test-prof.evilmartians.io for all options.

@ -29,38 +29,42 @@
require 'spec_helper'
describe EnumerationsController, 'routing', type: :routing do
context 'admin scoped' do
it {
expect(subject).to route(:get, 'admin/enumerations').to(controller: 'enumerations',
action: 'index')
}
it {
expect(get('admin/enumerations'))
.to route_to(controller: 'enumerations',
action: 'index')
}
it {
expect(subject).to route(:get, 'admin/enumerations/new').to(controller: 'enumerations',
action: 'new')
}
it {
expect(get('admin/enumerations/new'))
.to route_to(controller: 'enumerations',
action: 'new')
}
it {
expect(subject).to route(:post, 'admin/enumerations').to(controller: 'enumerations',
action: 'create')
}
it {
expect(post('admin/enumerations'))
.to route_to(controller: 'enumerations',
action: 'create')
}
it {
expect(subject).to route(:get, 'admin/enumerations/1/edit').to(controller: 'enumerations',
action: 'edit',
id: '1')
}
it {
expect(get('admin/enumerations/1/edit'))
.to route_to(controller: 'enumerations',
action: 'edit',
id: '1')
}
it {
expect(subject).to route(:put, 'admin/enumerations/1').to(controller: 'enumerations',
action: 'update',
id: '1')
}
it {
expect(put('admin/enumerations/1'))
.to route_to(controller: 'enumerations',
action: 'update',
id: '1')
}
it {
expect(subject).to route(:delete, 'admin/enumerations/1').to(controller: 'enumerations',
action: 'destroy',
id: '1')
}
end
it {
expect(delete('admin/enumerations/1'))
.to route_to(controller: 'enumerations',
action: 'destroy',
id: '1')
}
end

@ -29,7 +29,7 @@
require 'spec_helper'
describe 'errors routing', type: :routing do
it { is_expected.to route(:get, '/404').to(controller: 'errors', action: 'not_found') }
it { is_expected.to route(:get, '/422').to(controller: 'errors', action: 'unacceptable') }
it { is_expected.to route(:get, '/500').to(controller: 'errors', action: 'internal_error') }
it { expect(get('/404')).to route_to(controller: 'errors', action: 'not_found') }
it { expect(get('/422')).to route_to(controller: 'errors', action: 'unacceptable') }
it { expect(get('/500')).to route_to(controller: 'errors', action: 'internal_error') }
end

@ -30,28 +30,32 @@ require 'spec_helper'
describe ForumsController, type: :routing do
it {
expect(subject).to route(:get, '/projects/world_domination/forums').to(controller: 'forums',
action: 'index',
project_id: 'world_domination')
expect(get('/projects/world_domination/forums'))
.to route_to(controller: 'forums',
action: 'index',
project_id: 'world_domination')
}
it {
expect(subject).to route(:get, '/projects/world_domination/forums/new').to(controller: 'forums',
action: 'new',
project_id: 'world_domination')
expect(get('/projects/world_domination/forums/new'))
.to route_to(controller: 'forums',
action: 'new',
project_id: 'world_domination')
}
it {
expect(subject).to route(:post, '/projects/world_domination/forums').to(controller: 'forums',
action: 'create',
project_id: 'world_domination')
expect(post('/projects/world_domination/forums'))
.to route_to(controller: 'forums',
action: 'create',
project_id: 'world_domination')
}
it {
expect(subject).to route(:get, '/projects/world_domination/forums/44').to(controller: 'forums',
action: 'show',
project_id: 'world_domination',
id: '44')
expect(get('/projects/world_domination/forums/44'))
.to route_to(controller: 'forums',
action: 'show',
project_id: 'world_domination',
id: '44')
}
it {
@ -64,37 +68,42 @@ describe ForumsController, type: :routing do
}
it {
expect(subject).to route(:get, '/projects/world_domination/forums/44/edit').to(controller: 'forums',
action: 'edit',
project_id: 'world_domination',
id: '44')
expect(get('/projects/world_domination/forums/44/edit'))
.to route_to(controller: 'forums',
action: 'edit',
project_id: 'world_domination',
id: '44')
}
it {
expect(subject).to route(:put, '/projects/world_domination/forums/44').to(controller: 'forums',
action: 'update',
project_id: 'world_domination',
id: '44')
expect(put('/projects/world_domination/forums/44'))
.to route_to(controller: 'forums',
action: 'update',
project_id: 'world_domination',
id: '44')
}
it {
expect(subject).to route(:delete, '/projects/world_domination/forums/44').to(controller: 'forums',
action: 'destroy',
project_id: 'world_domination',
id: '44')
expect(delete('/projects/world_domination/forums/44'))
.to route_to(controller: 'forums',
action: 'destroy',
project_id: 'world_domination',
id: '44')
}
it 'connects GET /projects/:project/forums/:forum/move to forums#move' do
expect(get('/projects/1/forums/1/move')).to route_to(controller: 'forums',
action: 'move',
project_id: '1',
id: '1')
expect(get('/projects/1/forums/1/move'))
.to route_to(controller: 'forums',
action: 'move',
project_id: '1',
id: '1')
end
it 'connects POST /projects/:project/forums/:forum/move to forums#move' do
expect(post('/projects/1/forums/1/move')).to route_to(controller: 'forums',
action: 'move',
project_id: '1',
id: '1')
expect(post('/projects/1/forums/1/move'))
.to route_to(controller: 'forums',
action: 'move',
project_id: '1',
id: '1')
end
end

@ -30,74 +30,86 @@ require 'spec_helper'
describe 'groups routes', type: :routing do
it {
expect(subject).to route(:get, '/admin/groups').to(controller: 'groups',
action: 'index')
expect(get('/admin/groups'))
.to route_to(controller: 'groups',
action: 'index')
}
it {
expect(subject).to route(:get, '/admin/groups/new').to(controller: 'groups',
action: 'new')
expect(get('/admin/groups/new'))
.to route_to(controller: 'groups',
action: 'new')
}
it {
expect(subject).to route(:post, '/admin/groups').to(controller: 'groups',
action: 'create')
expect(post('/admin/groups'))
.to route_to(controller: 'groups',
action: 'create')
}
it {
expect(subject).to route(:get, '/groups/4').to(controller: 'groups',
action: 'show',
id: '4')
expect(get('/groups/4'))
.to route_to(controller: 'groups',
action: 'show',
id: '4')
}
it {
expect(subject).to route(:get, '/admin/groups/4/edit').to(controller: 'groups',
action: 'edit',
id: '4')
expect(get('/admin/groups/4/edit'))
.to route_to(controller: 'groups',
action: 'edit',
id: '4')
}
it {
expect(subject).to route(:put, '/admin/groups/4').to(controller: 'groups',
action: 'update',
id: '4')
expect(put('/admin/groups/4'))
.to route_to(controller: 'groups',
action: 'update',
id: '4')
}
it {
expect(subject).to route(:delete, '/admin/groups/4').to(controller: 'groups',
action: 'destroy',
id: '4')
expect(delete('/admin/groups/4'))
.to route_to(controller: 'groups',
action: 'destroy',
id: '4')
}
it {
expect(subject).to route(:post, '/admin/groups/4/members').to(controller: 'groups',
action: 'add_users',
id: '4')
expect(post('/admin/groups/4/members'))
.to route_to(controller: 'groups',
action: 'add_users',
id: '4')
}
it {
expect(subject).to route(:delete, '/admin/groups/4/members/5').to(controller: 'groups',
action: 'remove_user',
id: '4',
user_id: '5')
expect(delete('/admin/groups/4/members/5'))
.to route_to(controller: 'groups',
action: 'remove_user',
id: '4',
user_id: '5')
}
it {
expect(subject).to route(:post, '/admin/groups/4/memberships').to(controller: 'groups',
action: 'create_memberships',
id: '4')
expect(post('/admin/groups/4/memberships'))
.to route_to(controller: 'groups',
action: 'create_memberships',
id: '4')
}
it {
expect(subject).to route(:put, '/admin/groups/4/memberships/5').to(controller: 'groups',
action: 'edit_membership',
id: '4',
membership_id: '5')
expect(put('/admin/groups/4/memberships/5'))
.to route_to(controller: 'groups',
action: 'edit_membership',
id: '4',
membership_id: '5')
}
it {
expect(subject).to route(:delete, '/admin/groups/4/memberships/5').to(controller: 'groups',
action: 'destroy_membership',
id: '4',
membership_id: '5')
expect(delete('/admin/groups/4/memberships/5'))
.to route_to(controller: 'groups',
action: 'destroy_membership',
id: '4',
membership_id: '5')
}
end

@ -29,30 +29,33 @@
require 'spec_helper'
describe MembersController, type: :routing do
context 'project scoped' do
context 'with project scope' do
it {
expect(subject).to route(:post, '/projects/5234/members').to(controller: 'members',
action: 'create',
project_id: '5234')
expect(post('/projects/5234/members'))
.to route_to(controller: 'members',
action: 'create',
project_id: '5234')
}
it {
expect(subject).to route(:get, '/projects/5234/members/autocomplete_for_member')
.to(controller: 'members',
action: 'autocomplete_for_member',
project_id: '5234')
expect(get('/projects/5234/members/autocomplete_for_member'))
.to route_to(controller: 'members',
action: 'autocomplete_for_member',
project_id: '5234')
}
end
it {
expect(subject).to route(:put, '/members/5234').to(controller: 'members',
action: 'update',
id: '5234')
expect(put('/members/5234'))
.to route_to(controller: 'members',
action: 'update',
id: '5234')
}
it {
expect(subject).to route(:delete, '/members/5234').to(controller: 'members',
action: 'destroy',
id: '5234')
expect(delete('/members/5234'))
.to route_to(controller: 'members',
action: 'destroy',
id: '5234')
}
end

@ -29,53 +29,61 @@
require 'spec_helper'
describe MessagesController, 'routing', type: :routing do
context 'project scoped' do
context 'with forum scope' do
it {
expect(subject).to route(:get, '/forums/lala/topics/new').to(controller: 'messages',
action: 'new',
forum_id: 'lala')
expect(get('/forums/lala/topics/new'))
.to route_to(controller: 'messages',
action: 'new',
forum_id: 'lala')
}
it {
expect(subject).to route(:post, '/forums/lala/topics').to(controller: 'messages',
action: 'create',
forum_id: 'lala')
expect(post('/forums/lala/topics'))
.to route_to(controller: 'messages',
action: 'create',
forum_id: 'lala')
}
end
it {
expect(subject).to route(:get, '/topics/2').to(controller: 'messages',
action: 'show',
id: '2')
expect(get('/topics/2'))
.to route_to(controller: 'messages',
action: 'show',
id: '2')
}
it {
expect(subject).to route(:get, '/topics/22/edit').to(controller: 'messages',
action: 'edit',
id: '22')
expect(get('/topics/22/edit'))
.to route_to(controller: 'messages',
action: 'edit',
id: '22')
}
it {
expect(subject).to route(:put, '/topics/22').to(controller: 'messages',
action: 'update',
id: '22')
expect(put('/topics/22'))
.to route_to(controller: 'messages',
action: 'update',
id: '22')
}
it {
expect(subject).to route(:delete, '/topics/555').to(controller: 'messages',
action: 'destroy',
id: '555')
expect(delete('/topics/555'))
.to route_to(controller: 'messages',
action: 'destroy',
id: '555')
}
it {
expect(subject).to route(:get, '/topics/22/quote').to(controller: 'messages',
action: 'quote',
id: '22')
expect(get('/topics/22/quote'))
.to route_to(controller: 'messages',
action: 'quote',
id: '22')
}
it {
expect(subject).to route(:post, '/topics/555/reply').to(controller: 'messages',
action: 'reply',
id: '555')
expect(post('/topics/555/reply'))
.to route_to(controller: 'messages',
action: 'reply',
id: '555')
}
end

@ -29,17 +29,19 @@
require 'spec_helper'
describe News::CommentsController, 'routing', type: :routing do
context 'news scoped' do
context 'with news scope' do
it {
expect(subject).to route(:post, '/news/567/comments').to(controller: 'news/comments',
action: 'create',
news_id: '567')
expect(post('/news/567/comments'))
.to route_to(controller: 'news/comments',
action: 'create',
news_id: '567')
}
end
it {
expect(subject).to route(:delete, '/comments/15').to(controller: 'news/comments',
action: 'destroy',
id: '15')
expect(delete('/comments/15'))
.to route_to(controller: 'news/comments',
action: 'destroy',
id: '15')
}
end

@ -31,9 +31,10 @@ require 'spec_helper'
describe NewsController, 'routing', type: :routing do
context 'project scoped' do
it {
expect(subject).to route(:get, '/projects/567/news').to(controller: 'news',
action: 'index',
project_id: '567')
expect(get('/projects/567/news'))
.to route_to(controller: 'news',
action: 'index',
project_id: '567')
}
it do
@ -45,21 +46,24 @@ describe NewsController, 'routing', type: :routing do
end
it {
expect(subject).to route(:get, '/projects/567/news/new').to(controller: 'news',
action: 'new',
project_id: '567')
expect(get('/projects/567/news/new'))
.to route_to(controller: 'news',
action: 'new',
project_id: '567')
}
it {
expect(subject).to route(:post, '/projects/567/news').to(controller: 'news',
action: 'create',
project_id: '567')
expect(post('/projects/567/news'))
.to route_to(controller: 'news',
action: 'create',
project_id: '567')
}
end
it {
expect(subject).to route(:get, '/news').to(controller: 'news',
action: 'index')
expect(get('/news'))
.to route_to(controller: 'news',
action: 'index')
}
it do
@ -70,32 +74,37 @@ describe NewsController, 'routing', type: :routing do
end
it {
expect(subject).to route(:get, '/news/2').to(controller: 'news',
action: 'show',
id: '2')
expect(get('/news/2'))
.to route_to(controller: 'news',
action: 'show',
id: '2')
}
it {
expect(subject).to route(:get, '/news/234').to(controller: 'news',
action: 'show',
id: '234')
expect(get('/news/234'))
.to route_to(controller: 'news',
action: 'show',
id: '234')
}
it {
expect(subject).to route(:get, '/news/567/edit').to(controller: 'news',
action: 'edit',
id: '567')
expect(get('/news/567/edit'))
.to route_to(controller: 'news',
action: 'edit',
id: '567')
}
it {
expect(subject).to route(:put, '/news/567').to(controller: 'news',
action: 'update',
id: '567')
expect(put('/news/567'))
.to route_to(controller: 'news',
action: 'update',
id: '567')
}
it {
expect(subject).to route(:delete, '/news/567').to(controller: 'news',
action: 'destroy',
id: '567')
expect(delete('/news/567'))
.to route_to(controller: 'news',
action: 'destroy',
id: '567')
}
end

@ -29,48 +29,54 @@
require 'spec_helper'
describe 'roles routes', type: :routing do
context 'admin scoped' do
it {
expect(subject).to route(:get, 'admin/roles').to(controller: 'roles',
action: 'index')
}
it {
expect(get('admin/roles'))
.to route_to(controller: 'roles',
action: 'index')
}
it {
expect(subject).to route(:get, 'admin/roles/new').to(controller: 'roles',
action: 'new')
}
it {
expect(get('admin/roles/new'))
.to route_to(controller: 'roles',
action: 'new')
}
it {
expect(subject).to route(:post, 'admin/roles').to(controller: 'roles',
action: 'create')
}
it {
expect(post('admin/roles'))
.to route_to(controller: 'roles',
action: 'create')
}
it {
expect(subject).to route(:get, 'admin/roles/1/edit').to(controller: 'roles',
action: 'edit',
id: '1')
}
it {
expect(get('admin/roles/1/edit'))
.to route_to(controller: 'roles',
action: 'edit',
id: '1')
}
it {
expect(subject).to route(:put, 'admin/roles/1').to(controller: 'roles',
action: 'update',
id: '1')
}
it {
expect(put('admin/roles/1'))
.to route_to(controller: 'roles',
action: 'update',
id: '1')
}
it {
expect(subject).to route(:delete, 'admin/roles/1').to(controller: 'roles',
action: 'destroy',
id: '1')
}
it {
expect(delete('admin/roles/1'))
.to route_to(controller: 'roles',
action: 'destroy',
id: '1')
}
it {
expect(subject).to route(:get, 'admin/roles/report').to(controller: 'roles',
action: 'report')
}
it {
expect(get('admin/roles/report'))
.to route_to(controller: 'roles',
action: 'report')
}
it {
expect(subject).to route(:put, 'admin/roles').to(controller: 'roles',
action: 'bulk_update')
}
end
it {
expect(put('admin/roles'))
.to route_to(controller: 'roles',
action: 'bulk_update')
}
end

@ -30,8 +30,9 @@ require 'spec_helper'
describe UsersController, 'routing', type: :routing do
it {
expect(subject).to route(:get, '/users').to(controller: 'users',
action: 'index')
expect(get('/users'))
.to route_to controller: 'users',
action: 'index'
}
it {
@ -42,9 +43,10 @@ describe UsersController, 'routing', type: :routing do
}
it {
expect(subject).to route(:get, '/users/44').to(controller: 'users',
action: 'show',
id: '44')
expect(get('/users/44'))
.to route_to controller: 'users',
action: 'show',
id: '44'
}
it {
@ -56,9 +58,10 @@ describe UsersController, 'routing', type: :routing do
}
it {
expect(subject).to route(:get, '/users/current').to(controller: 'users',
action: 'show',
id: 'current')
expect(get('/users/current'))
.to route_to controller: 'users',
action: 'show',
id: 'current'
}
it {
@ -70,26 +73,30 @@ describe UsersController, 'routing', type: :routing do
}
it {
expect(subject).to route(:get, '/users/new').to(controller: 'users',
action: 'new')
expect(get('/users/new'))
.to route_to controller: 'users',
action: 'new'
}
it {
expect(subject).to route(:get, '/users/444/edit').to(controller: 'users',
action: 'edit',
id: '444')
expect(get('/users/444/edit'))
.to route_to controller: 'users',
action: 'edit',
id: '444'
}
it {
expect(subject).to route(:get, '/users/222/edit/membership').to(controller: 'users',
action: 'edit',
id: '222',
tab: 'membership')
expect(get('/users/222/edit/membership'))
.to route_to controller: 'users',
action: 'edit',
id: '222',
tab: 'membership'
}
it {
expect(subject).to route(:post, '/users').to(controller: 'users',
action: 'create')
expect(post('/users'))
.to route_to controller: 'users',
action: 'create'
}
it {
@ -100,9 +107,10 @@ describe UsersController, 'routing', type: :routing do
}
it {
expect(subject).to route(:put, '/users/444').to(controller: 'users',
action: 'update',
id: '444')
expect(put('/users/444'))
.to route_to controller: 'users',
action: 'update',
id: '444'
}
it {
@ -122,14 +130,16 @@ describe UsersController, 'routing', type: :routing do
}
it {
expect(get('/users/1/deletion_info')).to route_to(controller: 'users',
action: 'deletion_info',
id: '1')
expect(get('/users/1/deletion_info'))
.to route_to controller: 'users',
action: 'deletion_info',
id: '1'
}
it {
expect(delete('/users/1')).to route_to(controller: 'users',
action: 'destroy',
id: '1')
expect(delete('/users/1'))
.to route_to controller: 'users',
action: 'destroy',
id: '1'
}
end

@ -30,58 +30,67 @@ require 'spec_helper'
describe 'versions routing', type: :routing do
it {
expect(subject).to route(:get, '/versions/1').to(controller: 'versions',
action: 'show',
id: '1')
expect(get('/versions/1'))
.to route_to(controller: 'versions',
action: 'show',
id: '1')
}
it {
expect(subject).to route(:get, '/versions/1/edit').to(controller: 'versions',
action: 'edit',
id: '1')
expect(get('/versions/1/edit'))
.to route_to(controller: 'versions',
action: 'edit',
id: '1')
}
it {
expect(subject).to route(:patch, '/versions/1').to(controller: 'versions',
action: 'update',
id: '1')
expect(patch('/versions/1'))
.to route_to(controller: 'versions',
action: 'update',
id: '1')
}
it {
expect(subject).to route(:delete, '/versions/1').to(controller: 'versions',
action: 'destroy',
id: '1')
expect(delete('/versions/1'))
.to route_to(controller: 'versions',
action: 'destroy',
id: '1')
}
it {
expect(subject).to route(:get, '/versions/1/status_by').to(controller: 'versions',
action: 'status_by',
id: '1')
expect(get('/versions/1/status_by'))
.to route_to(controller: 'versions',
action: 'status_by',
id: '1')
}
context 'project scoped' do
context 'with project scope' do
it {
expect(subject).to route(:get, '/projects/foo/versions/new').to(controller: 'versions',
action: 'new',
project_id: 'foo')
expect(get('/projects/foo/versions/new'))
.to route_to(controller: 'versions',
action: 'new',
project_id: 'foo')
}
it {
expect(subject).to route(:post, '/projects/foo/versions').to(controller: 'versions',
action: 'create',
project_id: 'foo')
expect(post('/projects/foo/versions'))
.to route_to(controller: 'versions',
action: 'create',
project_id: 'foo')
}
it {
expect(subject).to route(:put, '/projects/foo/versions/close_completed').to(controller: 'versions',
action: 'close_completed',
project_id: 'foo')
expect(put('/projects/foo/versions/close_completed'))
.to route_to(controller: 'versions',
action: 'close_completed',
project_id: 'foo')
}
it {
expect(subject).to route(:get, '/projects/foo/roadmap').to(controller: 'versions',
action: 'index',
project_id: 'foo')
expect(get('/projects/foo/roadmap'))
.to route_to(controller: 'versions',
action: 'index',
project_id: 'foo')
}
end
end

@ -30,66 +30,75 @@ require 'spec_helper'
describe WikiController, type: :routing do
describe 'routing' do
it {
expect(subject).to route(:get, '/projects/567/wiki').to(controller: 'wiki',
action: 'show',
project_id: '567')
}
it do
expect(get('/projects/567/wiki'))
.to route_to(controller: 'wiki',
action: 'show',
project_id: '567')
end
it 'connects GET /projects/:project_id/wiki/:name (without format) to wiki/show' do
expect(get('/projects/abc/wiki/blubs')).to route_to(controller: 'wiki',
action: 'show',
project_id: 'abc',
id: 'blubs')
expect(get('/projects/abc/wiki/blubs'))
.to route_to(controller: 'wiki',
action: 'show',
project_id: 'abc',
id: 'blubs')
end
it 'connects GET /projects/:project_id/wiki/:name (with a dot in it) to wiki/show' do
expect(get('/projects/abc/wiki/blubs.blubs')).to route_to(controller: 'wiki',
action: 'show',
project_id: 'abc',
id: 'blubs.blubs')
expect(get('/projects/abc/wiki/blubs.blubs'))
.to route_to(controller: 'wiki',
action: 'show',
project_id: 'abc',
id: 'blubs.blubs')
end
it 'connects GET /projects/:project_id/wiki/:name.html to wiki/show' do
expect(get('/projects/abc/wiki/blubs.markdown')).to route_to(controller: 'wiki',
action: 'show',
project_id: 'abc',
id: 'blubs',
format: 'markdown')
expect(get('/projects/abc/wiki/blubs.markdown'))
.to route_to(controller: 'wiki',
action: 'show',
project_id: 'abc',
id: 'blubs',
format: 'markdown')
end
it 'connects GET /projects/:project_id/wiki/new to wiki/new' do
expect(get('/projects/abc/wiki/new')).to route_to(controller: 'wiki',
action: 'new',
project_id: 'abc')
expect(get('/projects/abc/wiki/new'))
.to route_to(controller: 'wiki',
action: 'new',
project_id: 'abc')
end
it 'connects GET /projects/:project_id/wiki/:id/new to wiki/new_child' do
expect(get('/projects/abc/wiki/def/new')).to route_to(controller: 'wiki',
action: 'new_child',
project_id: 'abc',
id: 'def')
expect(get('/projects/abc/wiki/def/new'))
.to route_to(controller: 'wiki',
action: 'new_child',
project_id: 'abc',
id: 'def')
end
it 'connects POST /projects/:project_id/wiki/new to wiki/create' do
expect(post('/projects/abc/wiki/new')).to route_to(controller: 'wiki',
action: 'create',
project_id: 'abc')
expect(post('/projects/abc/wiki/new'))
.to route_to(controller: 'wiki',
action: 'create',
project_id: 'abc')
end
it {
expect(subject).to route(:get, '/projects/567/wiki/my_page/edit').to(controller: 'wiki',
action: 'edit',
project_id: '567',
id: 'my_page')
expect(get('/projects/567/wiki/my_page/edit'))
.to route_to(controller: 'wiki',
action: 'edit',
project_id: '567',
id: 'my_page')
}
it do
expect(get('/projects/abc/wiki/abc_wiki?version=3')).to route_to(controller: 'wiki',
action: 'show',
project_id: 'abc',
id: 'abc_wiki',
version: '3')
expect(get('/projects/abc/wiki/abc_wiki?version=3'))
.to route_to(controller: 'wiki',
action: 'show',
project_id: 'abc',
id: 'abc_wiki',
version: '3')
end
it 'connects GET /projects/:project_id/wiki/:id/parent_page to wiki/edit_parent_page' do
@ -109,96 +118,109 @@ describe WikiController, type: :routing do
end
it 'connects GET /projects/:project_id/wiki/:id/toc to wiki#index' do
expect(get('/projects/abc/wiki/blubs/toc')).to route_to(controller: 'wiki',
action: 'index',
project_id: 'abc',
id: 'blubs')
expect(get('/projects/abc/wiki/blubs/toc'))
.to route_to(controller: 'wiki',
action: 'index',
project_id: 'abc',
id: 'blubs')
end
it {
expect(subject).to route(:get, '/projects/1/wiki/CookBook_documentation/history').to(controller: 'wiki',
action: 'history',
project_id: '1',
id: 'CookBook_documentation')
expect(get('/projects/1/wiki/CookBook_documentation/history'))
.to route_to(controller: 'wiki',
action: 'history',
project_id: '1',
id: 'CookBook_documentation')
}
it {
expect(subject).to route(:get, '/projects/1/wiki/CookBook_documentation/diff').to(controller: 'wiki',
action: 'diff',
project_id: '1',
id: 'CookBook_documentation')
expect(get('/projects/1/wiki/CookBook_documentation/diff'))
.to route_to(controller: 'wiki',
action: 'diff',
project_id: '1',
id: 'CookBook_documentation')
}
it {
expect(subject).to route(:get, '/projects/1/wiki/CookBook_documentation/diff/2').to(controller: 'wiki',
action: 'diff',
project_id: '1',
id: 'CookBook_documentation',
version: '2')
expect(get('/projects/1/wiki/CookBook_documentation/diff/2'))
.to route_to(controller: 'wiki',
action: 'diff',
project_id: '1',
id: 'CookBook_documentation',
version: '2')
}
it {
expect(subject).to route(:get, '/projects/1/wiki/CookBook_documentation/diff/2/vs/1').to(controller: 'wiki',
action: 'diff',
project_id: '1',
id: 'CookBook_documentation',
version: '2',
version_from: '1')
expect(get('/projects/1/wiki/CookBook_documentation/diff/2/vs/1'))
.to route_to(controller: 'wiki',
action: 'diff',
project_id: '1',
id: 'CookBook_documentation',
version: '2',
version_from: '1')
}
it {
expect(subject).to route(:get, '/projects/1/wiki/CookBook_documentation/annotate/2').to(controller: 'wiki',
action: 'annotate',
project_id: '1',
id: 'CookBook_documentation',
version: '2')
expect(get('/projects/1/wiki/CookBook_documentation/annotate/2'))
.to route_to(controller: 'wiki',
action: 'annotate',
project_id: '1',
id: 'CookBook_documentation',
version: '2')
}
it {
expect(subject).to route(:get, '/projects/22/wiki/ladida/rename').to(controller: 'wiki',
action: 'rename',
project_id: '22',
id: 'ladida')
expect(get('/projects/22/wiki/ladida/rename'))
.to route_to(controller: 'wiki',
action: 'rename',
project_id: '22',
id: 'ladida')
}
it {
expect(subject).to route(:get, '/projects/567/wiki/index').to(controller: 'wiki',
action: 'index',
project_id: '567')
expect(get('/projects/567/wiki/index'))
.to route_to(controller: 'wiki',
action: 'index',
project_id: '567')
}
it {
expect(subject).to route(:get, '/projects/567/wiki/export').to(controller: 'wiki',
action: 'export',
project_id: '567')
expect(get('/projects/567/wiki/export'))
.to route_to(controller: 'wiki',
action: 'export',
project_id: '567')
}
it {
expect(subject).to route(:patch, '/projects/22/wiki/ladida/rename').to(controller: 'wiki',
action: 'rename',
project_id: '22',
id: 'ladida')
expect(patch('/projects/22/wiki/ladida/rename'))
.to route_to(controller: 'wiki',
action: 'rename',
project_id: '22',
id: 'ladida')
}
it {
expect(subject).to route(:post, '/projects/22/wiki/ladida/protect').to(controller: 'wiki',
action: 'protect',
project_id: '22',
id: 'ladida')
expect(post('/projects/22/wiki/ladida/protect'))
.to route_to(controller: 'wiki',
action: 'protect',
project_id: '22',
id: 'ladida')
}
it {
expect(subject).to route(:put, '/projects/567/wiki/my_page').to(controller: 'wiki',
action: 'update',
project_id: '567',
id: 'my_page')
expect(put('/projects/567/wiki/my_page'))
.to route_to(controller: 'wiki',
action: 'update',
project_id: '567',
id: 'my_page')
}
it {
expect(subject).to route(:delete, '/projects/22/wiki/ladida').to(controller: 'wiki',
action: 'destroy',
project_id: '22',
id: 'ladida')
expect(delete('/projects/22/wiki/ladida'))
.to route_to(controller: 'wiki',
action: 'destroy',
project_id: '22',
id: 'ladida')
}
end
end

@ -1,7 +0,0 @@
Shoulda::Matchers.configure do |config|
config.integrate do |with|
# Choose a test framework:
with.test_framework :rspec
with.library :rails
end
end
Loading…
Cancel
Save