require 'spec_helper' describe 'Routes' do routes { Sufia::Engine.routes } describe 'Homepage' do it 'should route the root url to the homepage controller' do { get: '/' }.should route_to(controller: 'homepage', action: 'index') end end describe 'GenericFile' do it 'should route to citation' do { get: '/files/1/citation' }.should route_to(controller: 'generic_files', action: 'citation', id: '1') end it 'should route to stats' do { get: '/files/1/stats' }.should route_to(controller: 'generic_files', action: 'stats', id: '1') end it 'should route to audit' do { post: '/files/7/audit' }.should route_to(controller: 'generic_files', action: 'audit', id: '7') end it 'should route to create' do { post: '/files' }.should route_to(controller: 'generic_files', action: 'create') end it 'should route to new' do { get: '/files/new' }.should route_to(controller: 'generic_files', action: 'new') end it 'should route to edit' do { get: '/files/3/edit' }.should route_to(controller: 'generic_files', action: 'edit', id: '3') end it "should route to show" do { get: '/files/4' }.should route_to(controller: 'generic_files', action: 'show', id: '4') end it "should route to update" do { put: '/files/5' }.should route_to(controller: 'generic_files', action: 'update', id: '5') end it "should route to destroy" do { delete: '/files/6' }.should route_to(controller: 'generic_files', action: 'destroy', id: '6') end it "should *not* route to index" do { get: '/files' }.should_not route_to(controller: 'generic_files', action: 'index') end end describe 'Batch' do it "should route to edit" do { get: '/batches/1/edit' }.should route_to(controller: 'batch', action: 'edit', id: '1') end it "should route to update" do { post: '/batches/2' }.should route_to(controller: 'batch', action: 'update', id: '2') end end describe 'Download' do it "should route to show" do { get: '/downloads/9' }.should route_to(controller: 'downloads', action: 'show', id: '9') end end describe 'Dashboard' do it "should route to dashboard" do { get: '/dashboard' }.should route_to(controller: 'dashboard', action: 'index') end it "should route to dashboard activity" do { get: '/dashboard/activity' }.should route_to(controller: 'dashboard', action: 'activity') end it "should route to my files tab" do { get: '/dashboard/files' }.should route_to(controller: 'my/files', action: 'index') end it "should route to my collections tab" do { get: '/dashboard/collections' }.should route_to(controller: 'my/collections', action: 'index') end it "should route to my highlighted tab" do { get: '/dashboard/highlights' }.should route_to(controller: 'my/highlights', action: 'index') end it "should route to my shared tab" do { get: '/dashboard/shares' }.should route_to(controller: 'my/shares', action: 'index') end end describe 'Advanced Search' do it "should route to search" do { get: '/search' }.should route_to(controller: 'advanced', action: 'index') end end describe 'Authorities' do it "should route to query" do { get: '/authorities/subject/bio' }.should route_to(controller: 'authorities', action: 'query', model: 'subject', term: 'bio') end end describe 'Users' do it 'should route to user trophies' do { post: '/users/bob135/trophy' }.should route_to(controller: 'users', action: 'toggle_trophy', id: 'bob135') end it 'should route to user profile' do { get: '/users/bob135' }.should route_to(controller: 'users', action: 'show', id: 'bob135') end it "should route to edit profile" do { get: '/users/bob135/edit' }.should route_to(controller: 'users', action: 'edit', id: 'bob135') end it "should route to update profile" do { put: '/users/bob135' }.should route_to(controller: 'users', action: 'update', id: 'bob135') end it "should route to user follow" do { post: '/users/bob135/follow' }.should route_to(controller: 'users', action: 'follow', id: 'bob135') end it "should route to user unfollow" do { post: '/users/bob135/unfollow' }.should route_to(controller: 'users', action: 'unfollow', id: 'bob135') end end describe "Directory" do it "should route to user" do { get: '/directory/user/xxx666' }.should route_to(controller: 'directory', action: 'user', uid: 'xxx666') end it "should route to user attribute" do { get: '/directory/user/zzz777/email' }.should route_to(controller: 'directory', action: 'user_attribute', uid: 'zzz777', attribute: 'email') end it "should route to group and allow periods" do { get: '/directory/group/all.staff' }.should route_to(controller: 'directory', action: 'group', cn: 'all.staff') end end describe "Notifications" do it "should have index" do expect( get: '/notifications').to route_to(controller: 'mailbox', action: 'index') expect(notifications_path).to eq '/notifications' end it "should allow deleting" do expect( delete: '/notifications/123').to route_to(controller: 'mailbox', action: 'destroy', id: '123') expect(notification_path(123)).to eq '/notifications/123' end it "should allow deleting all of them" do expect( delete: '/notifications/delete_all').to route_to(controller: 'mailbox', action: 'delete_all') expect(delete_all_notifications_path).to eq '/notifications/delete_all' end end describe "Contact Form" do it "should route to new" do { get: '/contact' }.should route_to(controller: 'contact_form', action: 'new') end it "should route to create" do { post: '/contact' }.should route_to(controller: 'contact_form', action: 'create') end end describe "Dynamically edited pages" do it "should route to about" do { get: '/about' }.should route_to(controller: 'pages', action: 'show', id: 'about_page') end end describe "Static Pages" do it "should route to help" do { get: '/help' }.should route_to(controller: 'static', action: 'help') end it "should route to terms" do { get: '/terms' }.should route_to(controller: 'static', action: 'terms') end it "should route to zotero" do { get: '/zotero' }.should route_to(controller: 'static', action: 'zotero') end it "should route to mendeley" do { get: '/mendeley' }.should route_to(controller: 'static', action: 'mendeley') end it "should route to versions" do { get: '/versions' }.should route_to(controller: 'static', action: 'versions') end it "should *not* route a bogus static page" do { get: '/awesome' }.should_not route_to(controller: 'static', action: 'awesome') end end describe "Catch-all" do it "should route non-existent routes to errors" do pending "The default route is turned off in testing, so that errors are raised" { get: '/awesome' }.should route_to(controller: 'errors', action: 'routing', error: 'awesome') end end end