Skip to content

Commit 60d764e

Browse files
committed
Merge pull request #292 from seuros/teammanage
team slug is citext now, restore previous admins for premium teams
2 parents 14c8682 + 9dd670a commit 60d764e

File tree

6 files changed

+38
-5
lines changed

6 files changed

+38
-5
lines changed

app/controllers/teams_controller.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ def create
9393
#end
9494

9595
def edit
96-
#TODO, change slug to citext
9796
@team = Team.find_by_slug(params[:slug])
9897
return head(:forbidden) unless current_user.belongs_to_team?(@team) || current_user.admin?
9998
@edit_mode = true

config/routes.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,9 @@
119119
# alerts GET /alerts(.:format) alerts#create
120120
# GET /alerts(.:format) alerts#index
121121
# follow_user POST /users/:username/follow(.:format) follows#create {:type=>:user}
122-
# teamname GET /team/:slug(.:format) teams#show
123122
# teamname_edit GET /team/:slug/edit(.:format) teams#edit
124123
# job GET /team/:slug(/:job_id)(.:format) teams#show
124+
# teamname GET /team/:slug(.:format) teams#show
125125
# accept_team GET /teams/:id/accept(.:format) teams#accept
126126
# record_exit_team POST /teams/:id/record-exit(.:format) teams#record_exit
127127
# visitors_team GET /teams/:id/visitors(.:format) teams#visitors
@@ -383,9 +383,9 @@
383383

384384
post '/users/:username/follow' => 'follows#create', as: :follow_user, :type => :user
385385

386-
get '/team/:slug' => 'teams#show', as: :teamname
387386
get '/team/:slug/edit' => 'teams#edit', as: :teamname_edit
388387
get '/team/:slug/(:job_id)' => 'teams#show', as: :job
388+
get '/team/:slug' => 'teams#show', as: :teamname
389389

390390
resources :teams do
391391
member do
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class ChangeTeamSlugToCitext < ActiveRecord::Migration
2+
def change
3+
change_column :teams, :slug, :citext, null: false, index: true , unique: true
4+
end
5+
end
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class RestorePremiumTeamAdmins < ActiveRecord::Migration
2+
def up
3+
premium_admins = Teams::Account.pluck(:admin_id)
4+
Teams::Member.where(user_id: premium_admins).update_all(role: 'admin')
5+
end
6+
7+
def down
8+
raise ActiveRecord::IrreversibleMigration
9+
end
10+
end

db/schema.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#
1212
# It's strongly recommended to check this file into your version control system.
1313

14-
ActiveRecord::Schema.define(:version => 20150109101515) do
14+
ActiveRecord::Schema.define(:version => 20150110140000) do
1515

1616
add_extension "citext"
1717
add_extension "hstore"
@@ -365,7 +365,7 @@
365365
t.decimal "score", :precision => 40, :scale => 30, :default => 0.0
366366
t.string "twitter"
367367
t.string "facebook"
368-
t.string "slug"
368+
t.citext "slug", :null => false
369369
t.boolean "premium", :default => false
370370
t.boolean "analytics", :default => false
371371
t.boolean "valid_jobs", :default => false

spec/routing/teams_routing_spec.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
RSpec.describe TeamsController, type: :routing do
2+
describe 'routing' do
3+
it 'routes to #show' do
4+
expect(get('/team/coderwall')).to route_to(controller: 'teams', action: 'show', slug: 'coderwall')
5+
end
6+
7+
it 'routes to #edit with ' do
8+
expect(get('/team/test-team/edit')).to route_to(controller: 'teams', action: 'edit', slug: 'test-team')
9+
end
10+
11+
it 'routes to #edit' do
12+
expect(get('/team/coderwall/edit')).to route_to(controller: 'teams', action: 'edit', slug: 'coderwall')
13+
end
14+
15+
it 'routes to #show with job id' do
16+
expect(get('/team/coderwall/666')).to route_to(controller: 'teams', action: 'show', slug: 'coderwall', job_id: '666')
17+
end
18+
end
19+
end

0 commit comments

Comments
 (0)