refinerycms-authentication 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -37,8 +37,6 @@ module Refinery
37
37
  end
38
38
 
39
39
  def edit
40
- @user = Refinery::User.find(params[:id])
41
-
42
40
  redirect_unless_user_editable!
43
41
 
44
42
  @selected_plugin_names = @user.plugins.collect(&:name)
@@ -81,20 +79,28 @@ module Refinery
81
79
 
82
80
  protected
83
81
 
84
- def load_available_plugins_and_roles
85
- @available_plugins = Refinery::Plugins.registered.in_menu.collect { |a|
86
- { :name => a.name, :title => a.title }
87
- }.sort_by { |a| a[:title] }
82
+ def find_user_with_slug
83
+ begin
84
+ find_user_without_slug
85
+ rescue ActiveRecord::RecordNotFound
86
+ @user = Refinery::User.all.detect{|u| u.to_param == params[:id]}
87
+ end
88
+ end
89
+ alias_method_chain :find_user, :slug
88
90
 
89
- @available_roles = Refinery::Role.all
90
- end
91
+ def load_available_plugins_and_roles
92
+ @available_plugins = Refinery::Plugins.registered.in_menu.collect { |a|
93
+ { :name => a.name, :title => a.title }
94
+ }.sort_by { |a| a[:title] }
95
+
96
+ @available_roles = Refinery::Role.all
97
+ end
91
98
 
92
99
  def redirect_unless_user_editable!
93
100
  unless current_refinery_user.can_edit?(@user)
94
101
  redirect_to(main_app.refinery_admin_users_path) and return
95
102
  end
96
103
  end
97
-
98
104
  end
99
105
  end
100
106
  end
@@ -42,7 +42,7 @@ module Refinery
42
42
  flash.now[:error] = if @refinery_user.email.blank?
43
43
  t('blank_email', :scope => 'refinery.users.forgot')
44
44
  else
45
- t('email_not_associated_with_account_html', :email => @refinery_user.email, :scope => 'refinery.users.forgot').html_safe
45
+ t('email_not_associated_with_account_html', :email => @refinery_user.email, :scope => 'refinery.users.forgot')
46
46
  end
47
47
  render :new
48
48
  end
@@ -87,7 +87,11 @@ module Refinery
87
87
  end
88
88
 
89
89
  def to_s
90
- username
90
+ username.to_s
91
+ end
92
+
93
+ def to_param
94
+ to_s.parameterize
91
95
  end
92
96
 
93
97
  end
@@ -28,7 +28,9 @@ Refinery::Core::Engine.routes.draw do
28
28
  raise exc
29
29
  end
30
30
  end
31
+ end
31
32
 
33
+ Refinery::Core::Engine.routes.append do
32
34
  namespace :admin, :path => 'refinery' do
33
35
  resources :users, :except => :show
34
36
  end
@@ -18,7 +18,7 @@ module Refinery
18
18
  :class_name => :'refinery/user',
19
19
  :title => 'username'
20
20
  }
21
- plugin.url = { :controller => '/refinery/admin/users' }
21
+ plugin.url = proc { Refinery::Core::Engine.routes.url_helpers.admin_users_path }
22
22
  end
23
23
  end
24
24
 
data/license.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # MIT License
2
2
 
3
- Copyright (c) 2005-2011 [Resolve Digital](http://www.resolvedigital.com)
3
+ Copyright (c) 2005-2012 [Resolve Digital](http://www.resolvedigital.com)
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -4,12 +4,12 @@ describe Refinery::Admin::UsersController do
4
4
  login_refinery_superuser
5
5
 
6
6
  shared_examples_for "new, create, update, edit and update actions" do
7
- it "should load roles" do
7
+ it "loads roles" do
8
8
  Refinery::Role.should_receive(:all).once{ [] }
9
9
  get :new
10
10
  end
11
11
 
12
- it "should load plugins" do
12
+ it "loads plugins" do
13
13
  plugins = Refinery::Plugins.new
14
14
  plugins.should_receive(:in_menu).once{ [] }
15
15
 
@@ -19,7 +19,7 @@ describe Refinery::Admin::UsersController do
19
19
  end
20
20
 
21
21
  describe "#new" do
22
- it "should render the new template" do
22
+ it "renders the new template" do
23
23
  get :new
24
24
  response.should be_success
25
25
  response.should render_template("refinery/admin/users/new")
@@ -29,7 +29,7 @@ describe Refinery::Admin::UsersController do
29
29
  end
30
30
 
31
31
  describe "#create" do
32
- it "should create a new user with valid params" do
32
+ it "creates a new user with valid params" do
33
33
  user = Refinery::User.new :username => "bob"
34
34
  user.should_receive(:save).once{ true }
35
35
  Refinery::User.should_receive(:new).once.with(instance_of(HashWithIndifferentAccess)){ user }
@@ -39,7 +39,7 @@ describe Refinery::Admin::UsersController do
39
39
 
40
40
  it_should_behave_like "new, create, update, edit and update actions"
41
41
 
42
- it "should re-render #new if there are errors" do
42
+ it "re-renders #new if there are errors" do
43
43
  user = Refinery::User.new :username => "bob"
44
44
  user.should_receive(:save).once{ false }
45
45
  Refinery::User.should_receive(:new).once.with(instance_of(HashWithIndifferentAccess)){ user }
@@ -50,8 +50,7 @@ describe Refinery::Admin::UsersController do
50
50
  end
51
51
 
52
52
  describe "#edit" do
53
- it "should render the edit template" do
54
- Refinery::User.should_receive(:find).at_least(1).times{ @refinery_superuser }
53
+ it "renders the edit template" do
55
54
  get :edit, :id => "1"
56
55
  response.should be_success
57
56
  response.should render_template("refinery/admin/users/edit")
@@ -61,7 +60,7 @@ describe Refinery::Admin::UsersController do
61
60
  end
62
61
 
63
62
  describe "#update" do
64
- it "should update a user" do
63
+ it "updates a user" do
65
64
  user = FactoryGirl.create(:refinery_user)
66
65
  Refinery::User.should_receive(:find).at_least(1).times{ user }
67
66
  put "update", :id => user.id.to_s, :user => {}
@@ -1,7 +1,7 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe "manage users" do
4
- login_refinery_user
4
+ login_refinery_superuser
5
5
 
6
6
  describe "new/create" do
7
7
  it "allows to create user" do
@@ -31,6 +31,20 @@ describe "manage users" do
31
31
  page.should have_content("cmsrefinery was successfully updated.")
32
32
  page.should have_content("cmsrefinery (cms@refinerycms.com)")
33
33
  end
34
+
35
+ let(:dotty_user) { FactoryGirl.create(:refinery_user, :username => 'user.name.with.lots.of.dots') }
36
+ it "accepts a username with a '.' in it" do
37
+ dotty_user # create the user
38
+ visit refinery.admin_users_path
39
+
40
+ page.should have_css("#sortable_#{dotty_user.id}")
41
+
42
+ within "#sortable_#{dotty_user.id}" do
43
+ click_link "Edit this user"
44
+ end
45
+
46
+ page.should have_css("form#edit_user_#{dotty_user.id}")
47
+ end
34
48
  end
35
49
 
36
50
  describe "destroy" do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: refinerycms-authentication
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease:
6
6
  segments:
7
7
  - 2
8
8
  - 0
9
- - 0
10
- version: 2.0.0
9
+ - 1
10
+ version: 2.0.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Philip Arndt
@@ -18,7 +18,7 @@ autorequire:
18
18
  bindir: bin
19
19
  cert_chain: []
20
20
 
21
- date: 2012-03-01 00:00:00 Z
21
+ date: 2012-03-06 00:00:00 Z
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
24
24
  prerelease: false
@@ -43,12 +43,12 @@ dependencies:
43
43
  requirements:
44
44
  - - "="
45
45
  - !ruby/object:Gem::Version
46
- hash: 15
46
+ hash: 13
47
47
  segments:
48
48
  - 2
49
49
  - 0
50
- - 0
51
- version: 2.0.0
50
+ - 1
51
+ version: 2.0.1
52
52
  version_requirements: *id002
53
53
  name: refinerycms-core
54
54
  type: :runtime