tb_core 1.3.0.beta2 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
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,4 +1,4 @@
1
- require 'spec_helper'
1
+ require 'rails_helper'
2
2
 
3
3
  describe Spud::Core do
4
4
 
@@ -7,27 +7,6 @@ describe Spud::Core do
7
7
  config.site_id = 0
8
8
  config.site_name = "Default Site"
9
9
  config.short_name = "default"
10
- config.multisite_mode_enabled = true
11
- config.multisite_config = [{:hosts => ["test.host"], :site_name =>"Site B", :short_name => 'site_b', :site_id => 1}]
12
- end
13
- end
14
-
15
- describe :site_config_for_id do
16
- it "should should return the default site config" do
17
- config = Spud::Core.site_config_for_id(0)
18
- config.should == {:site_name =>"Default Site", :short_name => 'default', :site_id => 0}
19
- end
20
-
21
- it "should return the config for Site B" do
22
- config = Spud::Core.site_config_for_id(1)
23
- config.should == {:hosts => ["test.host"], :site_name =>"Site B", :short_name => 'site_b', :site_id => 1}
24
- end
25
- end
26
-
27
- describe :default_site_config do
28
- it "should return the default site config" do
29
- config = Spud::Core.default_site_config
30
- config.should == {:site_name =>"Default Site", :short_name => 'default', :site_id => 0}
31
10
  end
32
11
  end
33
12
 
@@ -1,6 +1,6 @@
1
- require 'spec_helper'
1
+ require 'rails_helper'
2
2
 
3
- describe SpudRole do
3
+ describe SpudRole, :type => :model do
4
4
 
5
5
  before :each do
6
6
  @role = FactoryGirl.build(:spud_role)
@@ -13,8 +13,8 @@ describe SpudRole do
13
13
 
14
14
  describe "permissions" do
15
15
  it "should return an array of SpudPermission objects" do
16
- @role.permissions.should be_an_instance_of(Array)
17
- @role.permissions.first.should be_an_instance_of(SpudPermission)
16
+ expect(@role.permissions).to be_an_instance_of(Array)
17
+ expect(@role.permissions.first).to be_an_instance_of(SpudPermission)
18
18
  end
19
19
  end
20
20
 
@@ -23,14 +23,14 @@ describe SpudRole do
23
23
  original_count = @role.spud_role_permissions.length
24
24
  @role.permissions = [@full_access, @partial_access]
25
25
  @role.save
26
- @role.spud_role_permissions.length.should be > original_count
26
+ expect(@role.spud_role_permissions.length).to be > original_count
27
27
  end
28
28
  end
29
29
 
30
30
  describe "permission_tags" do
31
31
  it "should return an array of Strings" do
32
- @role.permission_tags.should be_an_instance_of(Array)
33
- @role.permission_tags.first.should be_an_instance_of(String)
32
+ expect(@role.permission_tags).to be_an_instance_of(Array)
33
+ expect(@role.permission_tags.first).to be_an_instance_of(String)
34
34
  end
35
35
  end
36
36
 
@@ -39,7 +39,7 @@ describe SpudRole do
39
39
  original_count = @role.spud_role_permissions.length
40
40
  @role.permission_tags = ['admin.test.full_access', 'admin.test.partial_access']
41
41
  @role.save
42
- @role.spud_role_permissions.length.should be > original_count
42
+ expect(@role.spud_role_permissions.length).to be > original_count
43
43
  end
44
44
  end
45
45
 
@@ -1,26 +1,26 @@
1
- require 'spec_helper'
1
+ require 'rails_helper'
2
2
 
3
- describe SpudUser do
3
+ describe SpudUser, :type => :model do
4
4
 
5
5
  describe ".full_name" do
6
6
  it "should return the full name if the first and last name are not blank" do
7
7
  u = FactoryGirl.build(:spud_user)
8
- u.full_name.should == "#{u.first_name} #{u.last_name}"
8
+ expect(u.full_name).to eq("#{u.first_name} #{u.last_name}")
9
9
  end
10
10
 
11
11
  it "should return only the last name if the first name is blank" do
12
12
  u = FactoryGirl.build(:spud_user, :first_name => nil)
13
- u.full_name.should == u.last_name
13
+ expect(u.full_name).to eq(u.last_name)
14
14
  end
15
15
 
16
16
  it "should return only the first name if the last name is blank" do
17
17
  u = FactoryGirl.build(:spud_user, :last_name => nil)
18
- u.full_name.should == u.first_name
18
+ expect(u.full_name).to eq(u.first_name)
19
19
  end
20
20
 
21
21
  it "should return the login if the first and last name are blank" do
22
22
  u = FactoryGirl.build(:spud_user, :first_name => nil, :last_name => nil)
23
- u.full_name.should == u.login
23
+ expect(u.full_name).to eq(u.login)
24
24
  end
25
25
  end
26
26
 
@@ -33,7 +33,7 @@ describe SpudUser do
33
33
 
34
34
  it "must match password confirmation before saving a new user" do
35
35
  u = FactoryGirl.build(:spud_user, :password_confirmation => '')
36
- u.save.should == false
36
+ expect(u.save).to eq(false)
37
37
  end
38
38
 
39
- end
39
+ end
@@ -0,0 +1,72 @@
1
+ # This file is copied to spec/ when you run 'rails generate rspec:install'
2
+ ENV["RAILS_ENV"] ||= 'test'
3
+
4
+ require File.expand_path("../dummy/config/environment.rb", __FILE__)
5
+ require 'spec_helper'
6
+ require 'authlogic_helper'
7
+ require 'rspec/rails'
8
+ require 'database_cleaner'
9
+ require 'simplecov'
10
+ require 'factory_girl_rails'
11
+ require 'shoulda'
12
+
13
+ SimpleCov.start 'rails'
14
+
15
+ # Add additional requires below this line. Rails is not loaded until this point!
16
+
17
+ # Requires supporting ruby files with custom matchers and macros, etc, in
18
+ # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
19
+ # run as spec files by default. This means that files in spec/support that end
20
+ # in _spec.rb will both be required and run as specs, causing the specs to be
21
+ # run twice. It is recommended that you do not name files matching this glob to
22
+ # end with _spec.rb. You can configure this pattern with the --pattern
23
+ # option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
24
+ #
25
+ # The following line is provided for convenience purposes. It has the downside
26
+ # of increasing the boot-up time by auto-requiring all files in the support
27
+ # directory. Alternatively, in the individual `*_spec.rb` files, manually
28
+ # require only the support files necessary.
29
+ #
30
+ # Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
31
+
32
+ # Checks for pending migrations before tests are run.
33
+ # If you are not using ActiveRecord, you can remove this line.
34
+ #ActiveRecord::Migration.maintain_test_schema!
35
+
36
+ RSpec.configure do |config|
37
+ config.raise_errors_for_deprecations!
38
+ config.infer_base_class_for_anonymous_controllers = false
39
+
40
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
41
+ # examples within a transaction, remove the following line or assign false
42
+ # instead of true.
43
+ config.use_transactional_fixtures = true
44
+
45
+ # RSpec Rails can automatically mix in different behaviours to your tests
46
+ # based on their file location, for example enabling you to call `get` and
47
+ # `post` in specs under `spec/controllers`.
48
+ #
49
+ # You can disable this behaviour by removing the line below, and instead
50
+ # explicitly tag your specs with their type, e.g.:
51
+ #
52
+ # RSpec.describe UsersController, :type => :controller do
53
+ # # ...
54
+ # end
55
+ #
56
+ # The different available types are documented in the features, such as in
57
+ # https://relishapp.com/rspec/rspec-rails/docs
58
+ # config.infer_spec_type_from_file_location!
59
+
60
+ # Clean the database as needed
61
+ # https://github.com/DatabaseCleaner/database_cleaner#rspec-example
62
+ config.before(:suite) do
63
+ DatabaseCleaner.strategy = :transaction
64
+ DatabaseCleaner.clean_with(:truncation)
65
+ end
66
+ config.around(:each) do |example|
67
+ DatabaseCleaner.cleaning do
68
+ example.run
69
+ end
70
+ end
71
+
72
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,43 +1,85 @@
1
- # Track code coverage
2
- require 'simplecov'
3
- SimpleCov.start 'rails' do
4
- # root "dummy/"
5
- add_filter "/factories/"
6
- end
7
-
8
- # This file is copied to spec/ when you run 'rails generate rspec:install'
9
- ENV["RAILS_ENV"] = 'test'
10
- require File.expand_path("../dummy/config/environment", __FILE__)
11
- require 'rspec/rails'
12
- require 'rspec/autorun'
13
- require 'database_cleaner'
14
- require 'shoulda'
15
- require 'factory_girl'
16
- require 'mocha'
17
- require 'capybara/rspec'
18
- require 'capybara/rails'
19
-
20
- # Requires supporting ruby files with custom matchers and macros, etc,
21
- # in spec/support/ and its subdirectories.
22
- ENGINE_RAILS_ROOT=File.join(File.dirname(__FILE__), '../')
23
- Dir[File.join(ENGINE_RAILS_ROOT,"spec/support/**/*.rb"), File.join(ENGINE_RAILS_ROOT,"factories/*")].each {|f| require f}
24
-
1
+ # This file was generated by the `rails generate rspec:install` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # The generated `.rspec` file contains `--require spec_helper` which will cause this
4
+ # file to always be loaded, without a need to explicitly require it in any files.
5
+ #
6
+ # Given that it is always loaded, you are encouraged to keep this file as
7
+ # light-weight as possible. Requiring heavyweight dependencies from this file
8
+ # will add to the boot time of your test suite on EVERY test run, even for an
9
+ # individual file that may not need all of that loaded. Instead, consider making
10
+ # a separate helper file that requires the additional dependencies and performs
11
+ # the additional setup, and require it from the spec files that actually need it.
12
+ #
13
+ # The `.rspec` file also contains a few flags that are not defaults but that
14
+ # users commonly want.
15
+ #
16
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
25
17
  RSpec.configure do |config|
26
- config.mock_with :mocha
27
- config.use_transactional_fixtures = true
28
- config.infer_base_class_for_anonymous_controllers = false
29
- config.include Capybara::DSL
30
-
31
- config.before(:suite) do
32
- DatabaseCleaner.strategy = :transaction
33
- DatabaseCleaner.clean_with(:truncation)
18
+ # rspec-expectations config goes here. You can use an alternate
19
+ # assertion/expectation library such as wrong or the stdlib/minitest
20
+ # assertions if you prefer.
21
+ config.expect_with :rspec do |expectations|
22
+ # This option will default to `true` in RSpec 4. It makes the `description`
23
+ # and `failure_message` of custom matchers include text for helper methods
24
+ # defined using `chain`, e.g.:
25
+ # be_bigger_than(2).and_smaller_than(4).description
26
+ # # => "be bigger than 2 and smaller than 4"
27
+ # ...rather than:
28
+ # # => "be bigger than 2"
29
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
34
30
  end
35
31
 
36
- config.before(:each) do
37
- DatabaseCleaner.start
32
+ # rspec-mocks config goes here. You can use an alternate test double
33
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
34
+ config.mock_with :rspec do |mocks|
35
+ # Prevents you from mocking or stubbing a method that does not exist on
36
+ # a real object. This is generally recommended, and will default to
37
+ # `true` in RSpec 4.
38
+ mocks.verify_partial_doubles = true
38
39
  end
39
40
 
40
- config.after(:each) do
41
- DatabaseCleaner.clean
41
+ # The settings below are suggested to provide a good initial experience
42
+ # with RSpec, but feel free to customize to your heart's content.
43
+ =begin
44
+ # These two settings work together to allow you to limit a spec run
45
+ # to individual examples or groups you care about by tagging them with
46
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
47
+ # get run.
48
+ config.filter_run :focus
49
+ config.run_all_when_everything_filtered = true
50
+
51
+ # Limits the available syntax to the non-monkey patched syntax that is recommended.
52
+ # For more details, see:
53
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
54
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
55
+ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
56
+ config.disable_monkey_patching!
57
+
58
+ # Many RSpec users commonly either run the entire suite or an individual
59
+ # file, and it's useful to allow more verbose output when running an
60
+ # individual spec file.
61
+ if config.files_to_run.one?
62
+ # Use the documentation formatter for detailed output,
63
+ # unless a formatter has already been configured
64
+ # (e.g. via a command-line flag).
65
+ config.default_formatter = 'doc'
42
66
  end
67
+
68
+ # Print the 10 slowest examples and example groups at the
69
+ # end of the spec run, to help surface which specs are running
70
+ # particularly slow.
71
+ config.profile_examples = 10
72
+
73
+ # Run specs in random order to surface order dependencies. If you find an
74
+ # order dependency and want to debug it, you can fix the order by providing
75
+ # the seed, which is printed after each run.
76
+ # --seed 1234
77
+ config.order = :random
78
+
79
+ # Seed global randomization in this process using the `--seed` CLI option.
80
+ # Setting this allows you to use `--seed` to deterministically reproduce
81
+ # test failures related to randomization by passing the same `--seed` value
82
+ # as the one that triggered the failure.
83
+ Kernel.srand config.seed
84
+ =end
43
85
  end