tb_core 1.3.0.beta2 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/admin/core/application.js +0 -3
  3. data/app/assets/stylesheets/admin/core/application.css.scss +6 -0
  4. data/app/controllers/admin/application_controller.rb +1 -32
  5. data/app/controllers/admin/dashboard_controller.rb +1 -17
  6. data/app/controllers/admin/password_resets_controller.rb +1 -1
  7. data/app/controllers/password_resets_controller.rb +1 -1
  8. data/app/controllers/spud/application_controller.rb +3 -21
  9. data/app/helpers/admin/application_helper.rb +0 -18
  10. data/app/helpers/spud/application_helper.rb +1 -13
  11. data/app/models/spud_user_session.rb +5 -0
  12. data/app/views/admin/dashboard/index.html.erb +1 -1
  13. data/app/views/admin/users/index.html.erb +3 -17
  14. data/app/views/layouts/admin/_search.html.erb +13 -0
  15. data/app/views/layouts/admin/application.html.erb +1 -1
  16. data/config/routes.rb +0 -4
  17. data/lib/generators/spud/module_generator.rb +5 -4
  18. data/lib/generators/spud/templates/views/admin/index.html.erb +2 -16
  19. data/lib/generators/spud/templates/views/admin/show.html.erb +1 -2
  20. data/lib/spud_core/configuration.rb +2 -27
  21. data/lib/spud_core/engine.rb +1 -1
  22. data/lib/spud_core/errors.rb +4 -2
  23. data/lib/spud_core/version.rb +1 -1
  24. data/lib/tb_core/form_builder.rb +3 -4
  25. data/spec/{support/authlogic_helper.rb → authlogic_helper.rb} +0 -0
  26. data/spec/controllers/admin/application_controller_spec.rb +8 -12
  27. data/spec/controllers/admin/dashboard_controller_spec.rb +13 -81
  28. data/spec/controllers/admin/password_reset_controller_spec.rb +28 -33
  29. data/spec/controllers/admin/settings_controller_spec.rb +7 -7
  30. data/spec/controllers/admin/setup_controller_spec.rb +10 -17
  31. data/spec/controllers/admin/user_sessions_controller_spec.rb +11 -11
  32. data/spec/controllers/admin/users_controller_spec.rb +40 -65
  33. data/spec/controllers/spud/application_controller_spec.rb +5 -5
  34. data/spec/dummy/app/assets/javascripts/admin/application.js +16 -0
  35. data/spec/dummy/app/assets/javascripts/application.js +16 -13
  36. data/spec/dummy/app/assets/stylesheets/admin/application.css.scss +3 -0
  37. data/spec/dummy/app/assets/stylesheets/application.css.scss +5 -0
  38. data/spec/dummy/app/controllers/application_controller.rb +1 -1
  39. data/spec/dummy/app/views/layouts/application.html.erb +22 -3
  40. data/spec/dummy/config/application.rb +5 -0
  41. data/spec/dummy/config/environments/production.rb +1 -1
  42. data/spec/dummy/config/environments/test.rb +1 -1
  43. data/spec/dummy/db/migrate/20141214200804_create_spud_admin_permissions.tb_core.rb +12 -0
  44. data/spec/dummy/db/migrate/20141214200805_create_spud_users.tb_core.rb +30 -0
  45. data/spec/dummy/db/migrate/20141214200806_add_time_zone_to_spud_user.tb_core.rb +7 -0
  46. data/spec/dummy/db/migrate/20141214200807_add_scope_to_spud_admin_permissions.tb_core.rb +7 -0
  47. data/spec/dummy/db/migrate/20141214200808_create_spud_user_settings.tb_core.rb +12 -0
  48. data/spec/dummy/db/migrate/20141214200809_create_spud_roles.tb_core.rb +11 -0
  49. data/spec/dummy/db/migrate/20141214200810_create_spud_permissions.tb_core.rb +11 -0
  50. data/spec/dummy/db/migrate/20141214200811_create_spud_role_permissions.tb_core.rb +12 -0
  51. data/spec/dummy/db/migrate/20141214200812_drop_spud_admin_permissions.tb_core.rb +16 -0
  52. data/spec/dummy/db/schema.rb +47 -47
  53. data/spec/factories/spud_admin_permission_factories.rb +10 -0
  54. data/spec/factories/spud_role_factories.rb +9 -0
  55. data/spec/factories/spud_user_factories.rb +31 -0
  56. data/spec/helpers/spud/admin/application_helper_spec.rb +11 -119
  57. data/spec/helpers/spud/application_helper_spec.rb +4 -59
  58. data/spec/lib/spud_core/configuration_spec.rb +1 -22
  59. data/spec/models/spud_role_spec.rb +8 -8
  60. data/spec/models/spud_user_spec.rb +8 -8
  61. data/spec/rails_helper.rb +72 -0
  62. data/spec/spec_helper.rb +78 -36
  63. metadata +93 -118
  64. data/app/controllers/sitemaps_controller.rb +0 -7
  65. data/app/views/sitemaps/show.xml.builder +0 -12
  66. data/spec/controllers/sitemap_controllers_spec.rb +0 -15
  67. data/spec/dummy/app/assets/stylesheets/application.css +0 -13
  68. data/spec/integration/admin_setup_spec.rb +0 -8
  69. data/spec/javascripts/date_picker_spec.js +0 -8
  70. data/spec/javascripts/support/jasmine.yml +0 -88
  71. data/spec/javascripts/support/jasmine_helper.rb +0 -11
  72. data/spec/views/layouts/admin/application.html.erb_spec.rb +0 -20
@@ -1,6 +1,7 @@
1
- require 'spec_helper'
1
+ require 'rails_helper'
2
+
3
+ RSpec.describe Admin::DashboardController, :type => :controller do
2
4
 
3
- describe Admin::DashboardController do
4
5
  before(:all) do
5
6
  Spud::Core.admin_applications += [{
6
7
  :name => 'Test App',
@@ -10,19 +11,17 @@ describe Admin::DashboardController do
10
11
  {
11
12
  :name => "dash app",
12
13
  :key => 'dash_app',
13
- :badge => ->(user) { return 1 }
14
+ :badge => ->(user){ 1 }
14
15
  }]
15
16
  end
16
17
 
17
18
  before(:each) do
18
19
  activate_authlogic
19
- @user = FactoryGirl.create(:spud_user)
20
- @user.role = FactoryGirl.create(:spud_role)
21
- @user.save()
20
+ @user = FactoryGirl.create(:spud_user, :role => FactoryGirl.create(:spud_role))
22
21
  SpudUserSession.create(@user)
23
22
  end
24
23
 
25
- describe :index do
24
+ describe 'index' do
26
25
  it "should display applications the current user has access to given that the current user is not a super admin" do
27
26
  @user.super_admin = false
28
27
  @user.role.permission_tags = ['admin.users.full_access']
@@ -30,7 +29,7 @@ describe Admin::DashboardController do
30
29
  @user.save()
31
30
  get :index
32
31
 
33
- assigns(:admin_applications).collect{|app| app[:name] }.should =~ ['Users']
32
+ expect(assigns(:admin_applications).collect{|app| app[:name] }).to include('Users')
34
33
  end
35
34
 
36
35
  it "should not display applications the current user does not have access to given that the current user is not a super admin" do
@@ -40,7 +39,7 @@ describe Admin::DashboardController do
40
39
  @user.save()
41
40
  get :index
42
41
 
43
- assigns(:admin_applications).collect{|app| app[:name] }.should_not include(:test_app)
42
+ expect(assigns(:admin_applications).collect{|app| app[:name] }).to_not include('Test App')
44
43
  end
45
44
 
46
45
  it "should display all the applications despite the users permissions given the current user is a super admin" do
@@ -49,83 +48,15 @@ describe Admin::DashboardController do
49
48
  @user.save
50
49
  get :index
51
50
 
52
- assigns(:admin_applications).collect{|app| app[:name] }.should =~ Spud::Core.admin_applications.collect{|app| app[:name] }
53
- end
54
- end
55
-
56
- describe :switch do
57
- before(:each) do
58
- Spud::Core.configure do |config|
59
- config.site_name = "Test Site"
60
- config.multisite_mode_enabled = true
61
- end
62
- @user.super_admin = true
63
- @user.save
64
- end
65
-
66
- context "when multisite select is not set" do
67
- it "should clear the session admin site" do
68
- get :switch, :multisite_select => nil
69
- session[:admin_site].should == 0
70
- end
71
-
72
- it "should redirect to the referer" do
73
- get :switch, :multisite_select => nil
74
- response.should be_redirect
75
- end
76
- end
77
-
78
- context "when multisite select is set" do
79
- context "and the selected site is configured" do
80
- before(:each) do
81
- Spud::Core.configure do |config|
82
- config.site_name = "Test Site"
83
- config.multisite_mode_enabled = true
84
- config.multisite_config = [{:hosts => ["test.host"], :site_name =>"Site B", :site_id => 1}]
85
-
86
- end
87
- end
88
-
89
- it "should set the session's admin site" do
90
- get :switch, :multisite_select => 1
91
- session[:admin_site].should == 1
92
-
93
- end
94
-
95
- it "should redirect" do
96
- get :switch, :multisite_select => 1
97
- response.should be_redirect
98
- end
99
- end
100
-
101
- context "and the selected site is not configured" do
102
- before(:each) do
103
- Spud::Core.configure do |config|
104
- config.site_name = "Test Site"
105
- config.multisite_mode_enabled = true
106
- config.multisite_config = []
107
- end
108
- end
109
-
110
- it "should set a flash error" do
111
- get :switch, :multisite_select => 1
112
- flash[:error].should_not be_blank
113
- end
114
-
115
- it "should redirect" do
116
- get :switch, :multisite_select => 1
117
- response.should be_redirect
118
- end
119
- end
51
+ expect(assigns(:admin_applications).collect{|app| app[:name] }).to eq(Spud::Core.admin_applications.collect{|app| app[:name] })
120
52
  end
121
53
  end
122
54
 
123
- describe :badges do
55
+ describe 'badges' do
124
56
  before(:each) do
125
57
  request.accept = "application/json"
126
58
  Spud::Core.configure do |config|
127
59
  config.site_name = "Test Site"
128
- config.multisite_mode_enabled = true
129
60
  end
130
61
  @user.super_admin = true
131
62
  @user.save
@@ -133,13 +64,14 @@ describe Admin::DashboardController do
133
64
 
134
65
  it "should respond with a json content type" do
135
66
  get :badges
136
- response.content_type.should eq("application/json")
67
+
137
68
  end
138
69
 
139
70
  it "should contain data array in reponse" do
140
71
  get :badges
141
72
  json = JSON.parse(response.body)
142
- assert json.has_key?("data")
73
+ expect(response.content_type).to eq("application/json")
74
+ expect(json).to have_key('data')
143
75
  end
144
76
 
145
77
  it "should have badge count 1 for dash app" do
@@ -1,91 +1,86 @@
1
- require 'spec_helper'
1
+ require 'rails_helper'
2
2
 
3
- describe Admin::PasswordResetsController do
4
- let(:user) { FactoryGirl.build(:spud_user, :id => 1) }
3
+ describe Admin::PasswordResetsController, :type => :controller do
5
4
 
6
- context :get do
7
- describe :index do
5
+ let(:user) { FactoryGirl.build(:spud_user, :id => 1, :perishable_token => "jfdlsafhbkvabuadfbds") }
6
+
7
+ context 'get' do
8
+ describe 'index' do
8
9
  it "should return success" do
9
10
  get :index
10
- response.should be_success
11
+ expect(response).to be_success
11
12
  end
12
13
  end
13
14
 
14
- describe :show do
15
+ describe 'show' do
15
16
  context "with a valid id" do
16
- before(:all) do
17
- SpudUser.stubs(:find_using_perishable_token).returns(user)
18
- end
19
-
20
17
  it "should render the edit form" do
18
+ allow(SpudUser).to receive(:find_using_perishable_token).and_return(user)
21
19
  get :show, :id => 1
22
- response.should be_success
20
+ expect(response).to be_success
23
21
  end
24
22
  end
25
23
 
26
24
  context "with an invalid id" do
27
- before(:all) do
28
- SpudUser.stubs(:find_using_perishable_token).returns(nil)
29
- end
30
-
31
25
  it "should redirect to the login form" do
26
+ allow(SpudUser).to receive(:find_using_perishable_token).and_return(nil)
32
27
  get :show, :id => user.id
33
- response.should redirect_to(admin_login_path)
28
+ expect(response).to redirect_to(admin_login_path)
34
29
  end
35
30
  end
36
31
  end
37
32
  end
38
33
 
39
- context :post do
34
+ context 'post' do
40
35
 
41
- describe :create do
36
+ describe 'create' do
42
37
  context "with a valid user email address submitted" do
43
- before(:each) do
44
- user.perishable_token = "jfdlsafhbkvabuadfbds"
45
- SpudUser.stubs(:find_by_email).returns(user)
46
- end
47
-
48
38
  it "should trigger the password notificiation" do
49
- CoreMailer.expects(:forgot_password_notification).returns(stub(:deliver))
50
- post :create, :email => user.email
39
+ allow(SpudUser).to receive(:find_by_email).and_return(user)
40
+
41
+ expect{ post :create, :email => user.email}.to change{
42
+ ActionMailer::Base.deliveries.count
43
+ }.by(1)
51
44
  end
52
45
 
53
46
  it "should redirect to the login form" do
47
+ allow(SpudUser).to receive(:find_by_email).and_return(user)
48
+
54
49
  post :create, :email => user.email
55
- response.should redirect_to(admin_login_path)
50
+ expect(response).to redirect_to(admin_login_path)
56
51
  end
57
52
  end
58
53
 
59
54
  context "with an invalid user email address submitted" do
60
55
  before(:each) do
61
- SpudUser.stubs(:find_by_email).returns(nil)
56
+ allow(SpudUser).to receive(:find_by_email).and_return(nil)
62
57
  end
63
58
  it "should re-render the password reset form" do
64
59
  post :create, :email => "invalid@email.com"
65
- response.should render_template("index")
60
+ expect(response).to render_template("index")
66
61
  end
67
62
  end
68
63
  end
69
64
 
70
- describe :update do
65
+ describe 'update' do
71
66
  let(:valid_data) { {:id => user.id, :spud_user => {:password => "password", :password_confirmation => "password"}}}
72
67
  let(:invalid_data) { {:id => user.id, :spud_user => {:password => "password", :password_confirmation => "drowssap"}}}
73
68
 
74
69
  before(:each) do
75
- SpudUser.stubs(:find_using_perishable_token).returns(user)
70
+ allow(SpudUser).to receive(:find_using_perishable_token).and_return(user)
76
71
  end
77
72
 
78
73
  context "with valid password entry" do
79
74
  it "should save and redirect to the login form" do
80
75
  post :update, valid_data
81
- response.should redirect_to(admin_login_path)
76
+ expect(response).to redirect_to(admin_login_path)
82
77
  end
83
78
  end
84
79
 
85
80
  context "with an invalid password entry" do
86
81
  it "should re-render the password form" do
87
82
  post :update, invalid_data
88
- response.should render_template("show")
83
+ expect(response).to render_template("show")
89
84
  end
90
85
  end
91
86
  end
@@ -1,6 +1,6 @@
1
- require 'spec_helper'
1
+ require 'rails_helper'
2
2
 
3
- describe Admin::SettingsController do
3
+ describe Admin::SettingsController, :type => :controller do
4
4
  before(:each) do
5
5
  activate_authlogic
6
6
  user = FactoryGirl.build(:spud_user)
@@ -8,22 +8,22 @@ describe Admin::SettingsController do
8
8
  SpudUserSession.create(user)
9
9
  end
10
10
 
11
- describe :edit do
11
+ describe 'edit' do
12
12
  it "should respond with success" do
13
13
  get :edit
14
- response.should be_success
14
+ expect(response).to be_success
15
15
  end
16
16
  end
17
17
 
18
- describe :update do
18
+ describe 'update' do
19
19
  it "should redirect to the settings page with a successful update" do
20
20
  put :update, :spud_user => {:first_name => "Mike"}
21
- response.should redirect_to(admin_settings_path)
21
+ expect(response).to redirect_to(admin_settings_path)
22
22
  end
23
23
 
24
24
  it "should put a message in the flash notice" do
25
25
  put :update, :spud_user => {:first_name => "Mike"}
26
- flash[:notice].should_not be_blank
26
+ expect(flash[:notice]).to_not be_blank
27
27
  end
28
28
  end
29
29
 
@@ -1,39 +1,32 @@
1
- require 'spec_helper'
1
+ require 'rails_helper'
2
2
 
3
- describe Admin::SetupController do
3
+ describe Admin::SetupController, :type => :controller do
4
4
 
5
- describe :new do
5
+ describe 'new' do
6
6
  it "should be successful" do
7
7
  get :new
8
8
 
9
- response.should be_success
10
- end
11
-
12
- it "should set a flash error message when a spud user exists" do
13
- SpudUser.stubs(:count).returns(1)
14
- get :new
15
-
16
- flash[:error].should_not be_blank
9
+ expect(response).to be_success
17
10
  end
18
11
 
19
12
  it "should redirect to the admin login form when there is already a user" do
20
- SpudUser.stubs(:count).returns(1)
13
+ allow(SpudUser).to receive(:count).and_return(1)
21
14
  get :new
22
15
 
23
- response.should redirect_to(admin_login_path)
16
+ expect(response).to redirect_to(admin_login_path)
24
17
  end
25
18
  end
26
19
 
27
- describe :create do
20
+ describe 'create' do
28
21
  it "should create a new user" do
29
- lambda {
22
+ expect{
30
23
  post :create, :spud_user => FactoryGirl.attributes_for(:spud_user)
31
- }.should change(SpudUser, :count).by(1)
24
+ }.to change(SpudUser, :count).by(1)
32
25
  end
33
26
 
34
27
  it "should redirect to the admin dashboard when first admin user has been created" do
35
28
  post :create, :spud_user => FactoryGirl.attributes_for(:spud_user)
36
- response.should redirect_to(admin_root_path)
29
+ expect(response).to redirect_to(admin_root_path)
37
30
  end
38
31
  end
39
32
  end
@@ -1,52 +1,52 @@
1
- require 'spec_helper'
1
+ require 'rails_helper'
2
2
 
3
- describe Admin::UserSessionsController do
3
+ describe Admin::UserSessionsController, :type => :controller do
4
4
  before(:each) do
5
5
  # activate_authlogic
6
6
  # SpudUserSession.create(FactoryGirl.build(:spud_user))
7
7
  end
8
8
 
9
- describe :new do
9
+ describe 'new' do
10
10
  it "should redirect to setup url if no users exist" do
11
11
  get :new
12
- response.should redirect_to(admin_setup_path)
12
+ expect(response).to redirect_to(admin_setup_path)
13
13
  end
14
14
 
15
15
  it "should render login form if users do exist" do
16
16
  u = FactoryGirl.create(:spud_user)
17
17
  u.save
18
18
  get :new
19
- response.should be_success
19
+ expect(response).to be_success
20
20
  end
21
21
  end
22
22
 
23
- describe :create do
23
+ describe 'create' do
24
24
  it "should rerender form when login is invalid" do
25
25
  post :create
26
- response.should be_success
26
+ expect(response).to be_success
27
27
  end
28
28
  it "should redirect to admin root if login is valid" do
29
29
  u = FactoryGirl.create(:spud_user,:login => "testuser")
30
30
  u.save
31
31
  user_session = {:login => "testuser", :password => "password"}
32
32
  post :create, :spud_user_session => user_session
33
- response.should redirect_to(admin_root_path)
33
+ expect(response).to redirect_to(admin_root_path)
34
34
  end
35
35
  end
36
36
 
37
- describe :destroy do
37
+ describe 'destroy' do
38
38
  it "should redirect to login after logout when no referer" do
39
39
  activate_authlogic
40
40
  SpudUserSession.create(FactoryGirl.build(:spud_user))
41
41
  delete :destroy
42
- response.should redirect_to(admin_login_path)
42
+ expect(response).to redirect_to(admin_login_path)
43
43
  end
44
44
  it "should redirect to the admin login page after logout" do
45
45
  request.env["HTTP_REFERER"] = "/"
46
46
  activate_authlogic
47
47
  SpudUserSession.create(FactoryGirl.build(:spud_user))
48
48
  delete :destroy
49
- response.should redirect_to("/admin/login")
49
+ expect(response).to redirect_to("/admin/login")
50
50
  end
51
51
  end
52
52
  end
@@ -1,6 +1,7 @@
1
- require 'spec_helper'
1
+ require 'rails_helper'
2
+
3
+ describe Admin::UsersController, :type => :controller do
2
4
 
3
- describe Admin::UsersController do
4
5
  before(:each) do
5
6
  activate_authlogic
6
7
  @user = SpudUserSession.create(FactoryGirl.build(:spud_user, :super_admin => true))
@@ -9,26 +10,26 @@ describe Admin::UsersController do
9
10
  Spud::Core.permissions.push(SpudPermission.new('admin.test.full_access', 'Test', [:test]))
10
11
  end
11
12
 
12
- describe :index do
13
+ describe 'index' do
13
14
  it "should return an array of users" do
14
15
  2.times {|x| FactoryGirl.create(:spud_user) }
15
16
  get :index
16
17
 
17
- assigns(:users).count.should be > 1
18
+ expect(assigns(:spud_users).count).to be > 1
18
19
  end
19
20
 
20
21
  it "should not return any users if there are no users" do
21
22
  get :index
22
23
 
23
- assigns(:users).count.should == 1 # the currently logged in user is the only user
24
+ expect(assigns(:spud_users).count).to eq(1) # the currently logged in user is the only user
24
25
  end
25
26
 
26
27
  it "should not allow access to users with NO permissions" do
27
28
  SpudUserSession.create(FactoryGirl.build(:spud_user, :super_admin => false))
28
29
  get :index
29
30
 
30
- response.code.should eq("403")
31
- response.should render_template('layouts/admin/error_page')
31
+ expect(response.code).to eq("403")
32
+ expect(response).to render_template('layouts/admin/error_page')
32
33
  end
33
34
 
34
35
  it "should allow access to users with the correct permissions" do
@@ -39,7 +40,7 @@ describe Admin::UsersController do
39
40
  SpudUserSession.create(u)
40
41
  get :index
41
42
 
42
- response.should be_success
43
+ expect(response).to be_success
43
44
  end
44
45
 
45
46
  it "should not allow access to users without a role, and redirect to render error page if the user has no permissions" do
@@ -48,8 +49,8 @@ describe Admin::UsersController do
48
49
  SpudUserSession.create(u)
49
50
  get :index
50
51
 
51
- response.code.should eq("403")
52
- response.should render_template('layouts/admin/error_page')
52
+ expect(response.code).to eq("403")
53
+ expect(response).to render_template('layouts/admin/error_page')
53
54
  end
54
55
 
55
56
  it "should not allow access to users with a role that contains no permissions, and render error page if the users has no other admin modules" do
@@ -59,8 +60,8 @@ describe Admin::UsersController do
59
60
  SpudUserSession.create(u)
60
61
  get :index
61
62
 
62
- response.code.should eq("403")
63
- response.should render_template('layouts/admin/error_page')
63
+ expect(response.code).to eq("403")
64
+ expect(response).to render_template('layouts/admin/error_page')
64
65
  end
65
66
 
66
67
  it "should not allow access to users without permission and render error page if the users has other admin modules" do
@@ -70,113 +71,87 @@ describe Admin::UsersController do
70
71
  SpudUserSession.create(u)
71
72
  get :index
72
73
 
73
- response.code.should eq("403")
74
- response.should render_template('layouts/admin/error_page')
74
+ expect(response.code).to eq("403")
75
+ expect(response).to render_template('layouts/admin/error_page')
75
76
  end
76
77
  end
77
78
 
78
- describe :show do
79
+ describe 'show' do
79
80
  it "should respond successfully" do
80
81
  user = FactoryGirl.create(:spud_user)
81
82
  get :show, :id => user.id
82
-
83
- response.should be_success
84
- end
85
-
86
- it "should show the user" do
87
- user = FactoryGirl.create(:spud_user)
88
- get :show, :id => user.id
89
-
90
- assigns(:user).id.should == user.id
83
+ expect(response).to be_success
91
84
  end
92
85
  end
93
86
 
94
- describe :new do
95
- it "should respond successfully" do
96
- get :new, :format => :js
97
-
98
- response.should be_success
99
- end
100
-
101
- it "should build a user object for the form" do
102
- get :new, :format => :js
103
-
104
- assigns(:user).should_not be_blank
87
+ describe 'new' do
88
+ it "should render the form" do
89
+ get :new, :format => :html
90
+ expect(response).to be_success
105
91
  end
106
92
  end
107
93
 
108
- describe :create do
94
+ describe 'create' do
109
95
  context "HTML format" do
110
96
  it "should create a new user with a valid form submission" do
111
- lambda {
97
+ expect {
112
98
  post :create, :spud_user => FactoryGirl.attributes_for(:spud_user)
113
- }.should change(SpudUser, :count).by(1)
114
- response.should be_success
99
+ }.to change(SpudUser, :count).by(1)
100
+ expect(response).to be_success
115
101
  end
116
102
 
117
103
  it "should not create a user with an invalid form entry" do
118
- lambda {
104
+ expect {
119
105
  post :create, :spud_user => FactoryGirl.attributes_for(:spud_user, :email => nil)
120
- }.should_not change(SpudUser, :count)
106
+ }.to_not change(SpudUser, :count)
121
107
  end
122
108
  end
123
109
  end
124
110
 
125
- describe :edit do
111
+ describe 'edit' do
126
112
  context "HTML format" do
127
113
  it "should load the correct user for the edit form" do
128
114
  user = FactoryGirl.create(:spud_user)
129
115
  get :edit, :id => user.id
130
116
 
131
- assigns(:user).id.should == user.id
132
- end
133
- end
134
-
135
- context "JS format" do
136
- it "should load the correct user for the edit form" do
137
- user = FactoryGirl.create(:spud_user)
138
- get :edit, :id => user.id, :format => :js
139
-
140
- assigns(:user).id.should == user.id
117
+ expect(assigns(:user).id).to eq(user.id)
141
118
  end
142
-
143
119
  end
144
-
145
120
  end
146
121
 
147
- describe :update do
122
+ describe 'update' do
148
123
  it "should update the email when the first name attribute is changed" do
149
124
  user = FactoryGirl.create(:spud_user)
150
125
  new_name = "Adam"
151
- lambda {
126
+ expect {
152
127
  put :update, :id => user.id, :spud_user => user.attributes.merge!(:first_name => new_name)
153
128
  user.reload
154
- }.should change(user, :first_name).to(new_name)
129
+ }.to change(user, :first_name).to(new_name)
155
130
  end
156
131
 
157
132
  it "should redirect to the admin users show view after a successful update" do
158
133
  user = FactoryGirl.create(:spud_user)
159
134
  put :update, :id => user.id, :spud_user => user.attributes.merge!(:first_name => "Adam")
160
135
 
161
- response.should redirect_to(admin_user_path(user))
136
+ expect(response).to redirect_to(admin_user_path(user))
162
137
  end
163
138
  end
164
139
 
165
- describe :destroy do
140
+ describe 'destroy' do
166
141
  it "should destroy the user" do
167
142
  user = FactoryGirl.create(:spud_user)
168
- lambda {
143
+ expect {
169
144
  delete :destroy, :id => user.id
170
- }.should change(SpudUser, :count).by(-1)
171
- response.should be_redirect
145
+ }.to change(SpudUser, :count).by(-1)
146
+ expect(response).to be_redirect
172
147
  end
173
148
 
174
149
  it "should destroy the user with the wrong id" do
175
150
  user = FactoryGirl.create(:spud_user)
176
- lambda {
151
+ expect {
177
152
  delete :destroy, :id => "23532"
178
- }.should_not change(SpudUser, :count)
179
- response.should be_redirect
153
+ }.to_not change(SpudUser, :count)
154
+ expect(response).to be_redirect
180
155
  end
181
156
  end
182
157
  end
@@ -1,14 +1,14 @@
1
- require 'spec_helper'
1
+ require 'rails_helper'
2
2
  require 'rspec/mocks'
3
3
  require 'rspec/mocks/standalone'
4
4
 
5
- describe Spud::ApplicationController do
5
+ describe Spud::ApplicationController, :type => :controller do
6
6
 
7
- describe :not_found do
7
+ describe 'not_found' do
8
8
  it 'throws a 404 error' do
9
9
  get :not_found
10
- response.code.should eq("404")
11
- response.should render_template('layouts/error_page')
10
+ expect(response.code).to eq('404')
11
+ expect(response).to render_template('layouts/error_page')
12
12
  end
13
13
  end
14
14
 
@@ -0,0 +1,16 @@
1
+ //= require_self
2
+ //= require_tree
3
+
4
+ (function(){
5
+
6
+ window.app = {
7
+ admin: {
8
+ init: function(){
9
+
10
+ }
11
+ }
12
+ };
13
+
14
+ $(document).ready(app.admin.init);
15
+
16
+ })();