Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Use double quotes consistently in specs

  • Loading branch information...
commit e2a706061444b6626ebb5534c49c3df68916ceb8 1 parent bbec534
@sferik authored
Showing with 165 additions and 165 deletions.
  1. +3 −3 spec/controllers/main_controller_spec.rb
  2. +21 −21 spec/helpers/application_helper_spec.rb
  3. +4 −4 spec/helpers/form_builder_spec.rb
  4. +3 −3 spec/integration/authorization/cancan_spec.rb
  5. +2 −2 spec/integration/basic/bulk_action/rails_admin_basic_bulk_action_spec.rb
  6. +1 −1  spec/integration/basic/create/rails_admin_namespaced_model_create_spec.rb
  7. +3 −3 spec/integration/basic/destroy/rails_admin_basic_destroy_spec.rb
  8. +1 −1  spec/integration/basic/edit/rails_admin_basic_edit_spec.rb
  9. +3 −3 spec/integration/basic/new/rails_admin_namespaced_model_new_spec.rb
  10. +12 −12 spec/integration/config/edit/rails_admin_config_edit_spec.rb
  11. +4 −4 spec/integration/config/list/rails_admin_config_list_spec.rb
  12. +7 −7 spec/integration/config/show/rails_admin_config_show_spec.rb
  13. +2 −2 spec/integration/history/rails_admin_history_spec.rb
  14. +4 −4 spec/integration/rails_admin_spec.rb
  15. +7 −7 spec/integration/relation_spec.rb
  16. +5 −5 spec/unit/abstract_model_spec.rb
  17. +2 −2 spec/unit/active_record_extension_spec.rb
  18. +2 −2 spec/unit/adapters/active_record/abstract_object_spec.rb
  19. +6 −6 spec/unit/adapters/active_record_spec.rb
  20. +1 −1  spec/unit/adapters/mongoid/abstract_object_spec.rb
  21. +6 −6 spec/unit/adapters/mongoid_spec.rb
  22. +2 −2 spec/unit/config/actions/base_spec.rb
  23. +16 −16 spec/unit/config/actions_spec.rb
  24. +38 −38 spec/unit/config/fields/base_spec.rb
  25. +2 −2 spec/unit/config/sections_spec.rb
  26. +8 −8 spec/unit/config_spec.rb
View
6 spec/controllers/main_controller_spec.rb
@@ -38,12 +38,12 @@
end
describe "#get_sort_hash" do
- it 'should work with belongs_to associations with label method virtual' do
+ it "should work with belongs_to associations with label method virtual" do
controller.params = { :sort => "parent_category", :model_name =>"categories" }
expect(controller.send(:get_sort_hash, RailsAdmin.config(Category))).to eq({:sort=>"categories.parent_category_id", :sort_reverse=>true})
end
- it 'should work with belongs_to associations with label method real column' do
+ it "should work with belongs_to associations with label method real column" do
controller.params = { :sort => "team", :model_name =>"players" }
expect(controller.send(:get_sort_hash, RailsAdmin.config(Player))).to eq({:sort=>"teams.name", :sort_reverse=>true})
end
@@ -174,7 +174,7 @@ class TeamWithNumberedPlayers < Team
end
describe "sanitize_params_for!" do
- it 'sanitize params recursively in nested forms' do
+ it "sanitize params recursively in nested forms" do
RailsAdmin.config Comment do
configure :created_at do
show
View
42 spec/helpers/application_helper_spec.rb
@@ -6,8 +6,8 @@
controller.stub(:authorized?).and_return(true)
end
- describe '#current_action?' do
- it 'should return true if current_action, false otherwise' do
+ describe "#current_action?" do
+ it "should return true if current_action, false otherwise" do
@action = RailsAdmin::Config::Actions.find(:index)
expect(helper.current_action?(RailsAdmin::Config::Actions.find(:index))).to be_true
@@ -15,8 +15,8 @@
end
end
- describe '#action' do
- it 'should return action by :custom_key' do
+ describe "#action" do
+ it "should return action by :custom_key" do
RailsAdmin.config do |config|
config.actions do
dashboard do
@@ -27,7 +27,7 @@
expect(helper.action(:my_custom_dashboard_key)).to be
end
- it 'should return only visible actions' do
+ it "should return only visible actions" do
RailsAdmin.config do |config|
config.actions do
dashboard do
@@ -39,7 +39,7 @@
expect(helper.action(:dashboard)).to be_nil
end
- it 'should return only visible actions, passing all bindings' do
+ it "should return only visible actions, passing all bindings" do
RailsAdmin.config do |config|
config.actions do
member :test_bindings do
@@ -58,7 +58,7 @@
end
describe "#actions" do
- it 'should return actions by type' do
+ it "should return actions by type" do
abstract_model = RailsAdmin::AbstractModel.new(Player)
object = FactoryGirl.create :player
expect(helper.actions(:all, abstract_model, object).map(&:custom_key)).to eq([:dashboard, :index, :show, :new, :edit, :export, :delete, :bulk_delete, :history_show, :history_index, :show_in_app])
@@ -67,7 +67,7 @@
expect(helper.actions(:member, abstract_model, object).map(&:custom_key)).to eq([:show, :edit, :delete, :history_show, :show_in_app])
end
- it 'should only return visible actions, passing bindings correctly' do
+ it "should only return visible actions, passing bindings correctly" do
RailsAdmin.config do |config|
config.actions do
member :test_bindings do
@@ -131,7 +131,7 @@
end
describe "#menu_for" do
- it 'passes model and object as bindings and generates a menu, excluding non-get actions' do
+ it "passes model and object as bindings and generates a menu, excluding non-get actions" do
RailsAdmin.config do |config|
config.actions do
dashboard
@@ -180,14 +180,14 @@
end
describe "#main_navigation" do
- it 'should show included models' do
+ it "should show included models" do
RailsAdmin.config do |config|
config.included_models = [Ball, Comment]
end
expect(helper.main_navigation).to match /(nav\-header).*(Navigation).*(Balls).*(Comments)/m
end
- it 'should not draw empty navigation labels' do
+ it "should not draw empty navigation labels" do
RailsAdmin.config do |config|
config.included_models = [Ball, Comment, Comment::Confirmed]
config.model Comment do
@@ -201,7 +201,7 @@
expect(helper.main_navigation).not_to match /(nav\-header).*(Navigation).*(Balls).*(Commentz).*(Confirmed).*(Comment)/m
end
- it 'should not show unvisible models' do
+ it "should not show unvisible models" do
RailsAdmin.config do |config|
config.included_models = [Ball, Comment]
config.model Comment do
@@ -230,7 +230,7 @@
expect(helper.main_navigation).to match /(nav\-header).*(Navigation).*(Hardballs)/m
end
- it 'should "nest" in navigation label' do
+ it "should nest in navigation label" do
RailsAdmin.config do |config|
config.included_models = [Comment]
config.model Comment do
@@ -240,7 +240,7 @@
expect(helper.main_navigation).to match /(nav\-header).*(commentable).*(Comments)/m
end
- it 'should "nest" in parent model' do
+ it "should nest in parent model" do
RailsAdmin.config do |config|
config.included_models = [Player, Comment]
config.model Comment do
@@ -250,7 +250,7 @@
expect(helper.main_navigation).to match /(Players).*(nav\-level\-1).*(Comments)/m
end
- it 'should order' do
+ it "should order" do
RailsAdmin.config do |config|
config.included_models = [Player, Comment]
end
@@ -263,15 +263,15 @@
end
end
- describe '#static_navigation' do
- it 'should show not show static nav if no static links defined' do
+ describe "#static_navigation" do
+ it "should show not show static nav if no static links defined" do
RailsAdmin.config do |config|
config.navigation_static_links = {}
end
expect(helper.static_navigation).to be_empty
end
- it 'should show links if defined' do
+ it "should show links if defined" do
RailsAdmin.config do |config|
config.navigation_static_links = {
'Test Link' => 'http://www.google.com'
@@ -280,7 +280,7 @@
expect(helper.static_navigation).to match /Test Link/
end
- it 'should show default header if navigation_static_label not defined in config' do
+ it "should show default header if navigation_static_label not defined in config" do
RailsAdmin.config do |config|
config.navigation_static_links = {
'Test Link' => 'http://www.google.com'
@@ -289,7 +289,7 @@
expect(helper.static_navigation).to match I18n.t('admin.misc.navigation_static_label')
end
- it 'should show custom header if defined' do
+ it "should show custom header if defined" do
RailsAdmin.config do |config|
config.navigation_static_label = "Test Header"
config.navigation_static_links = {
@@ -301,7 +301,7 @@
end
describe "#bulk_menu" do
- it 'should include all visible bulkable actions' do
+ it "should include all visible bulkable actions" do
RailsAdmin.config do |config|
config.actions do
index
View
8 spec/helpers/form_builder_spec.rb
@@ -1,17 +1,17 @@
require 'spec_helper'
describe "RailsAdmin::FormBuilder" do
- describe '#generate' do
+ describe "#generate" do
before do
helper.stub(:authorized?).and_return(true)
(@object = Player.new).save
@builder = RailsAdmin::FormBuilder.new(:player, @object, helper, {}, nil)
@builder.stub(:field_for).and_return("field")
end
-
- it 'should not add additional error div from default ActionView::Base.field_error_proc' do
+
+ it "should not add additional error div from default ActionView::Base.field_error_proc" do
expect(@builder.generate({ :action => :create, :model_config => RailsAdmin.config(Player) })).not_to have_css(".field_with_errors")
expect(@builder.generate({ :action => :create, :model_config => RailsAdmin.config(Player) })).to have_css(".control-group.error")
end
end
-end
+end
View
6 spec/integration/authorization/cancan_spec.rb
@@ -185,7 +185,7 @@ def initialize(user)
end
describe "with history role" do
- it 'shows links to history action' do
+ it "shows links to history action" do
@user.update_attributes(:roles => [:admin, :read_player, :history_player])
@player = FactoryGirl.create :player
@@ -206,7 +206,7 @@ def initialize(user)
end
describe "with show in app role" do
- it 'shows links to show in app action' do
+ it "shows links to show in app action" do
@user.update_attributes(:roles => [:admin, :read_player, :show_in_app_player])
@player = FactoryGirl.create :player
@@ -229,7 +229,7 @@ def initialize(user)
end
describe "with all roles" do
- it 'shows links to all actions' do
+ it "shows links to all actions" do
@user.update_attributes(:roles => [:admin, :manage_player])
@player = FactoryGirl.create :player
View
4 spec/integration/basic/bulk_action/rails_admin_basic_bulk_action_spec.rb
@@ -9,14 +9,14 @@
end
describe "bulk_delete" do
- it 'should show names of to-be-deleted players' do
+ it "should show names of to-be-deleted players" do
page.driver.post(bulk_action_path(:bulk_action => 'bulk_delete', :model_name => "player", :bulk_ids => @players.map(&:id)))
@players.each { |player| should have_content(player.name) }
end
end
describe "bulk_export" do
- it 'should show form for export' do
+ it "should show form for export" do
visit index_path(:model_name => "player")
click_link "Export found Players"
@players.each { |player| should have_content("Select fields to export") }
View
2  spec/integration/basic/create/rails_admin_namespaced_model_create_spec.rb
@@ -4,7 +4,7 @@
subject { page }
- it 'should create object with correct attributes' do
+ it "should create object with correct attributes" do
visit new_path(:model_name => "cms~basic_page")
fill_in "cms_basic_page[title]", :with => "Hello"
View
6 spec/integration/basic/destroy/rails_admin_basic_destroy_spec.rb
@@ -61,8 +61,8 @@
end
end
- describe 'destroy from show page' do
- it 'should redirect to the index instead of trying to show the deleted object' do
+ describe "destroy from show page" do
+ it "should redirect to the index instead of trying to show the deleted object" do
@player = FactoryGirl.create :player
visit show_path(:model_name => 'player', :id => @player.id)
visit delete_path(:model_name => "player", :id => @player.id)
@@ -71,7 +71,7 @@
expect(URI.parse(page.current_url).path).to eq(index_path(:model_name => 'player'))
end
- it 'should redirect back to the object on error' do
+ it "should redirect back to the object on error" do
Player.any_instance.stub(:destroy_hook).and_return false
@player = FactoryGirl.create :player
visit show_path(:model_name => 'player', :id => @player.id)
View
2  spec/integration/basic/edit/rails_admin_basic_edit_spec.rb
@@ -42,7 +42,7 @@
describe "readonly associations" do
- it 'should not be editable' do
+ it "should not be editable" do
@league = FactoryGirl.create :league
visit edit_path(:model_name => "league", :id => @league.id)
should_not have_selector('select#league_team_ids')
View
6 spec/integration/basic/new/rails_admin_namespaced_model_new_spec.rb
@@ -5,13 +5,13 @@
subject { page }
describe "AbstractModel#to_param" do
- it 'turns namespaces into prefixes with ~' do
+ it "turns namespaces into prefixes with ~" do
expect(RailsAdmin::AbstractModel.new("Cms::BasicPage").to_param).to eq('cms~basic_page')
end
end
describe "ApplicationController#to_model_name" do
- it 'turns cms~basic_page into Cms::BasicPage' do
+ it "turns cms~basic_page into Cms::BasicPage" do
expect(RailsAdmin::ApplicationController.new.to_model_name('cms~basic_page')).to eq('Cms::BasicPage')
end
end
@@ -21,7 +21,7 @@
visit new_path(:model_name => "cms~basic_page")
end
- it 'should have correct input field names' do
+ it "should have correct input field names" do
should have_selector("label[for=cms_basic_page_title]")
should have_selector("input#cms_basic_page_title[name='cms_basic_page[title]']")
should have_selector("label[for=cms_basic_page_content]")
View
24 spec/integration/config/edit/rails_admin_config_edit_spec.rb
@@ -452,7 +452,7 @@ class HelpTest < Tableless
end
it "should be globally renameable by type" do
- RailsAdmin.config 'Team' do
+ RailsAdmin.config Team do
edit do
fields_of_type :string do
label { "#{label} (STRING)" }
@@ -531,7 +531,7 @@ class HelpTest < Tableless
end
it "should be globally hideable by type" do
- RailsAdmin.config 'Team' do
+ RailsAdmin.config Team do
edit do
fields_of_type :string do
hide
@@ -591,8 +591,8 @@ class HelpTest < Tableless
end
end
- describe 'bindings' do
- it 'should be present at creation time' do
+ describe "bindings" do
+ it "should be present at creation time" do
RailsAdmin.config do |config|
config.excluded_models = []
end
@@ -614,8 +614,8 @@ class HelpTest < Tableless
end
end
- describe 'nested form' do
- it 'should work' do
+ describe "nested form" do
+ it "should work" do
@record = FactoryGirl.create :field_test
@record.nested_field_tests = [NestedFieldTest.create!(:title => 'title 1'), NestedFieldTest.create!(:title => 'title 2')]
visit edit_path(:model_name => "field_test", :id => @record.id)
@@ -629,7 +629,7 @@ class HelpTest < Tableless
expect(@record.nested_field_tests[0].title).to eq('nested field test title 1 edited')
end
- it 'should set bindings[:object] to nested object' do
+ it "should set bindings[:object] to nested object" do
RailsAdmin.config(NestedFieldTest) do
nested do
field :title do
@@ -645,7 +645,7 @@ class HelpTest < Tableless
expect(find('#field_test_nested_field_tests_attributes_0_title_field')).to have_content('NestedFieldTest')
end
- it 'should be desactivable' do
+ it "should be desactivable" do
visit new_path(:model_name => "field_test")
should have_selector('#field_test_nested_field_tests_attributes_field .add_nested_fields')
RailsAdmin.config(FieldTest) do
@@ -663,7 +663,7 @@ class HelpTest < Tableless
and_return({:allow_destroy=>true, :update_only=>false})
end
- it 'should not show add button when :update_only is true' do
+ it "should not show add button when :update_only is true" do
FieldTest.nested_attributes_options.stub(:[]).with(:nested_field_tests).
and_return({:allow_destroy=>true, :update_only=>true})
visit new_path(:model_name => "field_test")
@@ -671,7 +671,7 @@ class HelpTest < Tableless
should_not have_selector('#field_test_nested_field_tests_attributes_field .add_nested_fields')
end
- it 'should not show destroy button except for newly created when :allow_destroy is false' do
+ it "should not show destroy button except for newly created when :allow_destroy is false" do
@record = FieldTest.create
@record.nested_field_tests << NestedFieldTest.create!(:title => 'nested title 1')
FieldTest.nested_attributes_options.stub(:[]).with(:nested_field_tests).
@@ -692,8 +692,8 @@ class HelpTest < Tableless
end
end
- describe 'embedded model', :mongoid => true do
- it 'should work' do
+ describe "embedded model", :mongoid => true do
+ it "should work" do
@record = FactoryGirl.create :field_test
2.times.each{|i| @record.embeds.create :name => "embed #{i}"}
visit edit_path(:model_name => "field_test", :id => @record.id)
View
8 spec/integration/config/list/rails_admin_config_list_spec.rb
@@ -179,7 +179,7 @@
end
it "should be globally renameable by type" do
- RailsAdmin.config 'Fan' do
+ RailsAdmin.config Fan do
list do
fields_of_type :datetime do
label { "#{label} (datetime)" }
@@ -233,7 +233,7 @@
end
it "should have option to disable sortability by type globally" do
- RailsAdmin.config 'Fan' do
+ RailsAdmin.config Fan do
list do
fields_of_type :datetime do
sortable false
@@ -265,7 +265,7 @@
end
it "should have option to hide fields by type globally" do
- RailsAdmin.config 'Fan' do
+ RailsAdmin.config Fan do
list do
fields_of_type :datetime do
hide
@@ -423,7 +423,7 @@
end
end
- describe 'embedded model', :mongoid => true do
+ describe "embedded model", :mongoid => true do
it "should not show link to individual object's page" do
RailsAdmin.config FieldTest do
list do
View
14 spec/integration/config/show/rails_admin_config_show_spec.rb
@@ -22,25 +22,25 @@ def do_request
let(:uri) { show_path(:model_name => 'player', :id => @player.id, :format => :json) }
let(:body) { page.body }
- it 'should create a JSON uri' do
+ it "should create a JSON uri" do
expect(uri).to eq("/admin/player/#{@player.id}.json")
end
- it 'should contain the JSONified object' do
+ it "should contain the JSONified object" do
expect(body).to include(@player.to_json)
end
end
describe "compact_show_view" do
- it 'should hide empty fields in show view by default' do
+ it "should hide empty fields in show view by default" do
@player = FactoryGirl.create :player
visit show_path(:model_name => "league", :id => @player.id)
should_not have_css(".born_on_field")
end
- it 'should be disactivable' do
+ it "should be disactivable" do
RailsAdmin.config do |c|
c.compact_show_view = false
end
@@ -242,7 +242,7 @@ def do_request
end
it "should be globally renameable by type" do
- RailsAdmin.config 'Team' do
+ RailsAdmin.config Team do
show do
fields_of_type :string do
label { "#{label} (STRING)" }
@@ -298,7 +298,7 @@ def do_request
end
it "should be globally hideable by type" do
- RailsAdmin.config 'Team' do
+ RailsAdmin.config Team do
show do
fields_of_type :string do
hide
@@ -318,7 +318,7 @@ def do_request
end
end
- describe 'embedded model', :mongoid => true do
+ describe "embedded model", :mongoid => true do
it "should not show link to individual object's page" do
@record = FactoryGirl.create :field_test
2.times.each{|i| @record.embeds.create :name => "embed #{i}"}
View
4 spec/integration/history/rails_admin_history_spec.rb
@@ -68,11 +68,11 @@
end
end
- it 'should get latest ones' do
+ it "should get latest ones" do
expect(RailsAdmin::History.latest.count).to eq(100)
end
- it 'should get latest ones orderly' do
+ it "should get latest ones orderly" do
latest = RailsAdmin::History.latest
expect(latest.first.message).to eq("change 100")
expect(latest.last.message).to eq("change 1")
View
8 spec/integration/rails_admin_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe "RailsAdmin" do
+describe RailsAdmin do
subject { page }
@@ -40,7 +40,7 @@
end
end
- describe 'hidden fields with default values' do
+ describe "hidden fields with default values" do
before (:each) do
RailsAdmin.config Player do
@@ -70,9 +70,9 @@
end
end
- describe '_current_user' do # https://github.com/sferik/rails_admin/issues/549
+ describe "_current_user" do # https://github.com/sferik/rails_admin/issues/549
- it 'should be accessible from the list view' do
+ it "should be accessible from the list view" do
RailsAdmin.config Player do
list do
field :name do
View
14 spec/integration/relation_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe 'table relations' do
+describe "table relations" do
before(:each) do
class RelTest < Tableless
@@ -15,20 +15,20 @@ class RelTest < Tableless
@fields = RailsAdmin.config(RelTest).create.fields
end
- describe 'column with nullable fk and no model validations' do
- it 'should be optional' do
+ describe "column with nullable fk and no model validations" do
+ it "should be optional" do
expect(@fields.find{ |f| f.name == :league }.required?).to be_false
end
end
- describe 'column with non-nullable fk and no model validations' do
- it 'should not be required' do
+ describe "column with non-nullable fk and no model validations" do
+ it "should not be required" do
expect(@fields.find{ |f| f.name == :division }.required?).to be_false
end
end
- describe 'column with nullable fk and a numericality model validation' do
- it 'should be required' do
+ describe "column with nullable fk and a numericality model validation" do
+ it "should be required" do
expect(@fields.find{ |f| f.name == :player }.required?).to be_true
end
end
View
10 spec/unit/abstract_model_spec.rb
@@ -1,13 +1,13 @@
require 'spec_helper'
describe RailsAdmin::AbstractModel do
- describe 'filters' do
+ describe "filters" do
before do
@abstract_model = RailsAdmin::AbstractModel.new('FieldTest')
end
- context 'on dates' do
- it 'lists elements within outbound limits' do
+ context "on dates" do
+ it "lists elements within outbound limits" do
date_format = I18n.t("admin.misc.filter_date_format", :default => I18n.t("admin.misc.filter_date_format", :locale => :en)).gsub('dd', '%d').gsub('mm', '%m').gsub('yy', '%Y')
FactoryGirl.create(:field_test, :date_field => Date.strptime("01/01/2012", date_format))
@@ -23,8 +23,8 @@
end
end
- context 'on datetimes' do
- it 'lists elements within outbound limits' do
+ context "on datetimes" do
+ it "lists elements within outbound limits" do
FactoryGirl.create(:field_test, :datetime_field => Time.local(2012, 1, 1, 23, 59, 59))
FactoryGirl.create(:field_test, :datetime_field => Time.local(2012, 1, 2, 0, 0, 0))
FactoryGirl.create(:field_test, :datetime_field => Time.local(2012, 1, 3, 23, 59, 59))
View
4 spec/unit/active_record_extension_spec.rb
@@ -1,8 +1,8 @@
require 'spec_helper'
require File.expand_path('../../../config/initializers/active_record_extensions', __FILE__)
-describe 'ActiveRecord::Base', :active_record => true do
- describe '#safe_send' do
+describe "ActiveRecord::Base", :active_record => true do
+ describe "#safe_send" do
it "only calls #read_attribute once" do
@player = Player.new
@player.number = 23
View
4 spec/unit/adapters/active_record/abstract_object_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe "AbstractObject", :active_record => true do
+describe "RailsAdmin::Adapters::ActiveRecord::AbstractObject", :active_record => true do
describe "proxy" do
let(:object) { mock("object") }
let(:abstract_object) { RailsAdmin::Adapters::ActiveRecord::AbstractObject.new(object) }
@@ -119,7 +119,7 @@
end
describe "object_label_method" do
- it 'should be configurable' do
+ it "should be configurable" do
RailsAdmin.config League do
object_label_method { :custom_name }
end
View
12 spec/unit/adapters/active_record_spec.rb
@@ -1,12 +1,12 @@
require 'spec_helper'
require 'timecop'
-describe 'RailsAdmin::Adapters::ActiveRecord', :active_record => true do
+describe "RailsAdmin::Adapters::ActiveRecord", :active_record => true do
before do
@like = ::ActiveRecord::Base.configurations[Rails.env]['adapter'] == "postgresql" ? 'ILIKE' : 'LIKE'
end
- describe '#associations' do
+ describe "#associations" do
before :all do
RailsAdmin::AbstractModel.reset_polymorphic_parents
@@ -49,11 +49,11 @@ class ARComment < ActiveRecord::Base
RailsAdmin::AbstractModel.reset_polymorphic_parents
end
- it 'lists associations' do
+ it "lists associations" do
expect(@post.associations.map{|a|a[:name].to_s}).to match_array ['a_r_blog', 'a_r_categories', 'a_r_comments']
end
- it 'list associations types in supported [:belongs_to, :has_and_belongs_to_many, :has_many, :has_one]' do
+ it "list associations types in supported [:belongs_to, :has_and_belongs_to_many, :has_many, :has_one]" do
expect((@post.associations + @blog.associations + @user.associations).map{|a|a[:type]}.uniq.map(&:to_s)).to match_array ['belongs_to', 'has_and_belongs_to_many', 'has_many', 'has_one']
end
@@ -339,14 +339,14 @@ class ARComment < ActiveRecord::Base
end
- it 'supports date type query' do
+ it "supports date type query" do
expect(@abstract_model.send(:filter_conditions, { "date_field" => { "1" => { :v => ["", "01/02/2012", "01/03/2012"], :o => 'between' } } })).to eq(["((field_tests.date_field BETWEEN ? AND ?))", Date.new(2012,1,2), Date.new(2012,1,3)])
expect(@abstract_model.send(:filter_conditions, { "date_field" => { "1" => { :v => ["", "01/03/2012", ""], :o => 'between' } } } )).to eq(["((field_tests.date_field >= ?))", Date.new(2012,1,3)])
expect(@abstract_model.send(:filter_conditions, { "date_field" => { "1" => { :v => ["", "", "01/02/2012"], :o => 'between' } } } )).to eq(["((field_tests.date_field <= ?))", Date.new(2012,1,2)])
expect(@abstract_model.send(:filter_conditions, { "date_field" => { "1" => { :v => ["01/02/2012"], :o => 'default' } } } )).to eq(["((field_tests.date_field BETWEEN ? AND ?))", Date.new(2012,1,2), Date.new(2012,1,2)])
end
- it 'supports datetime type query' do
+ it "supports datetime type query" do
expect(@abstract_model.send(:filter_conditions, { "datetime_field" => { "1" => { :v => ["", "01/02/2012", "01/03/2012"], :o => 'between' } } } )).to eq(["((field_tests.datetime_field BETWEEN ? AND ?))", Time.local(2012,1,2), Time.local(2012,1,3).end_of_day])
expect(@abstract_model.send(:filter_conditions, { "datetime_field" => { "1" => { :v => ["", "01/03/2012", ""], :o => 'between' } } } )).to eq(["((field_tests.datetime_field >= ?))", Time.local(2012,1,3)])
expect(@abstract_model.send(:filter_conditions, { "datetime_field" => { "1" => { :v => ["", "", "01/02/2012"], :o => 'between' } } } )).to eq(["((field_tests.datetime_field <= ?))", Time.local(2012,1,2).end_of_day])
View
2  spec/unit/adapters/mongoid/abstract_object_spec.rb
@@ -1,7 +1,7 @@
require 'spec_helper'
require 'rails_admin/adapters/mongoid/abstract_object'
-describe "Mongoid::AbstractObject", :mongoid => true do
+describe "RailsAdmin::Adapters::Mongoid::AbstractObject", :mongoid => true do
before(:each) do
@players = FactoryGirl.create_list :player, 3
@team = RailsAdmin::Adapters::Mongoid::AbstractObject.new FactoryGirl.create :team
View
12 spec/unit/adapters/mongoid_spec.rb
@@ -1,8 +1,8 @@
require 'spec_helper'
require 'timecop'
-describe 'RailsAdmin::Adapters::Mongoid', :mongoid => true do
- describe '#associations' do
+describe "RailsAdmin::Adapters::Mongoid", :mongoid => true do
+ describe "#associations" do
before :all do
RailsAdmin::AbstractModel.reset_polymorphic_parents
@@ -67,11 +67,11 @@ class MongoNote
RailsAdmin::AbstractModel.reset_polymorphic_parents
end
- it 'lists associations' do
+ it "lists associations" do
expect(@post.associations.map{|a| a[:name]}).to match_array [:mongo_blog, :mongo_categories, :mongo_comments, :mongo_note]
end
- it 'reads correct and know types in [:belongs_to, :has_and_belongs_to_many, :has_many, :has_one]' do
+ it "reads correct and know types in [:belongs_to, :has_and_belongs_to_many, :has_many, :has_one]" do
expect((@post.associations + @blog.associations + @user.associations).map{|a|a[:type].to_s}.uniq).to match_array ['belongs_to', 'has_and_belongs_to_many', 'has_many', 'has_one']
end
@@ -693,14 +693,14 @@ class CustomValiated
expect(@abstract_model.send(:build_statement, :field, :string, "foo", "is")).to eq({:field => 'foo'})
end
- it 'supports date type query' do
+ it "supports date type query" do
expect(@abstract_model.send(:filter_conditions, { "date_field" => { "1" => { :v => ["", "01/02/2012", "01/03/2012"], :o => 'between' } } })).to eq({"$and" => [{"date_field" => {"$gte" => Date.new(2012,1,2), "$lte" => Date.new(2012,1,3)}}]})
expect(@abstract_model.send(:filter_conditions, { "date_field" => { "1" => { :v => ["", "01/03/2012", ""], :o => 'between' } } } )).to eq({"$and" => [{"date_field" => {"$gte" => Date.new(2012,1,3)}}]})
expect(@abstract_model.send(:filter_conditions, { "date_field" => { "1" => { :v => ["", "", "01/02/2012"], :o => 'between' } } } )).to eq({"$and" => [{"date_field" => {"$lte" => Date.new(2012,1,2)}}]})
expect(@abstract_model.send(:filter_conditions, { "date_field" => { "1" => { :v => ["01/02/2012"], :o => 'default' } } } )).to eq({"$and" => [{"date_field" => {"$gte" => Date.new(2012,1,2), "$lte" => Date.new(2012,1,2)}}]})
end
- it 'supports datetime type query' do
+ it "supports datetime type query" do
expect(@abstract_model.send(:filter_conditions, { "datetime_field" => { "1" => { :v => ["", "01/02/2012", "01/03/2012"], :o => 'between' } } } )).to eq({"$and" => [{"datetime_field" => {"$gte" => Time.local(2012,1,2), "$lte" => Time.local(2012,1,3).end_of_day}}]})
expect(@abstract_model.send(:filter_conditions, { "datetime_field" => { "1" => { :v => ["", "01/03/2012", ""], :o => 'between' } } } )).to eq({"$and" => [{"datetime_field" => {"$gte" => Time.local(2012,1,3)}}]})
expect(@abstract_model.send(:filter_conditions, { "datetime_field" => { "1" => { :v => ["", "", "01/02/2012"], :o => 'between' } } } )).to eq({"$and" => [{"datetime_field" => {"$lte" => Time.local(2012,1,2).end_of_day}}]})
View
4 spec/unit/config/actions/base_spec.rb
@@ -3,7 +3,7 @@
describe RailsAdmin::Config::Actions::Base do
describe "#visible?" do
- it 'should exclude models not referenced in the only array' do
+ it "should exclude models not referenced in the only array" do
RailsAdmin.config do |config|
config.actions do
index do
@@ -16,7 +16,7 @@
expect(RailsAdmin::Config::Actions.find(:index, {:controller => double(:authorized? => true), :abstract_model => RailsAdmin::AbstractModel.new(Cms::BasicPage)})).to be_visible
end
- it 'should exclude models referenced in the except array' do
+ it "should exclude models referenced in the except array" do
RailsAdmin.config do |config|
config.actions do
index do
View
32 spec/unit/config/actions_spec.rb
@@ -3,13 +3,13 @@
describe RailsAdmin::Config::Actions do
describe "default" do
- it 'should be as before' do
+ it "should be as before" do
expect(RailsAdmin::Config::Actions.all.map(&:key)).to eq([:dashboard, :index, :show, :new, :edit, :export, :delete, :bulk_delete, :history_show, :history_index, :show_in_app])
end
end
- describe 'find' do
- it 'should find by custom key' do
+ describe "find" do
+ it "should find by custom key" do
RailsAdmin.config do |config|
config.actions do
dashboard do
@@ -27,11 +27,11 @@
expect(RailsAdmin::Config::Actions.find(:show)).to be_a(RailsAdmin::Config::Actions::Show)
end
- it 'should return nil when no action is found by the custom key' do
+ it "should return nil when no action is found by the custom key" do
expect(RailsAdmin::Config::Actions.find(:non_existent_action_key)).to be_nil
end
- it 'should return visible action passing binding if controller binding is given, and pass action visible or not if no' do
+ it "should return visible action passing binding if controller binding is given, and pass action visible or not if no" do
RailsAdmin.config do |config|
config.actions do
root :custom_root do
@@ -46,7 +46,7 @@
expect(RailsAdmin::Config::Actions.find(:custom_root, {:controller => "controller"})).to be_a(RailsAdmin::Config::Actions::Base)
end
- it 'should check bindings[:abstract_model] visibility while checking action\'s visibility' do
+ it "should check bindings[:abstract_model] visibility while checking action\'s visibility" do
RailsAdmin.config Team do
hide
end
@@ -55,7 +55,7 @@
expect(RailsAdmin::Config::Actions.find(:index, {:controller => double(:authorized? => true), :abstract_model => RailsAdmin::AbstractModel.new(Team)})).to be_nil
end
- it 'should check bindings[:abstract_model] presence while checking action\'s visibility' do
+ it "should check bindings[:abstract_model] presence while checking action\'s visibility" do
RailsAdmin.config do |config|
config.excluded_models << Team
end
@@ -64,8 +64,8 @@
end
end
- describe 'all' do
- it 'should return all defined actions' do
+ describe "all" do
+ it "should return all defined actions" do
RailsAdmin.config do |config|
config.actions do
dashboard
@@ -76,7 +76,7 @@
expect(RailsAdmin::Config::Actions.all.map(&:key)).to eq([:dashboard, :index])
end
- it 'should restrict by scope' do
+ it "should restrict by scope" do
RailsAdmin.config do |config|
config.actions do
root :custom_root
@@ -89,7 +89,7 @@
expect(RailsAdmin::Config::Actions.all(:member).map(&:key)).to eq([:custom_member])
end
- it 'should return all visible actions passing binding if controller binding is given, and pass all actions if no' do
+ it "should return all visible actions passing binding if controller binding is given, and pass all actions if no" do
RailsAdmin.config do |config|
config.actions do
root :custom_root do
@@ -106,7 +106,7 @@
end
describe "customized through DSL" do
- it 'should add the one asked' do
+ it "should add the one asked" do
RailsAdmin.config do |config|
config.actions do
dashboard
@@ -118,7 +118,7 @@
expect(RailsAdmin::Config::Actions.all.map(&:key)).to eq([:dashboard, :index, :show])
end
- it 'should allow to customize the custom_key when customizing an existing action' do
+ it "should allow to customize the custom_key when customizing an existing action" do
RailsAdmin.config do |config|
config.actions do
dashboard do
@@ -130,7 +130,7 @@
expect(RailsAdmin::Config::Actions.all.map(&:key)).to eq([:dashboard])
end
- it 'should allow to change the key and the custom_key when "subclassing" an existing action' do
+ it "should allow to change the key and the custom_key when subclassing an existing action" do
RailsAdmin.config do |config|
config.actions do
root :my_dashboard_key, :dashboard do
@@ -143,7 +143,7 @@
expect(RailsAdmin::Config::Actions.all.map(&:class)).to eq([RailsAdmin::Config::Actions::Dashboard])
end
- it 'should not add the same custom_key twice' do
+ it "should not add the same custom_key twice" do
expect do
RailsAdmin.config do |config|
config.actions do
@@ -163,7 +163,7 @@
end.to raise_error("Action index already exist. Please change its custom key")
end
- it 'should add the same key with different custom key' do
+ it "should add the same key with different custom key" do
RailsAdmin.config do |config|
config.actions do
dashboard
View
76 spec/unit/config/fields/base_spec.rb
@@ -14,7 +14,7 @@
end
describe "#name" do
- it 'should be normalized to Symbol' do
+ it "should be normalized to Symbol" do
RailsAdmin.config Team do
field 'name'
end
@@ -30,15 +30,15 @@
[:commentable_id, :commentable_type]
end
- it 'should be empty by default' do
+ it "should be empty by default" do
expect(RailsAdmin.config(Team).fields.find{ |f| f.name == :name }.children_fields).to eq([])
end
- it 'should contain child key for belongs to associations' do
+ it "should contain child key for belongs to associations" do
expect(RailsAdmin.config(Team).fields.find{ |f| f.name == :division }.children_fields).to eq([:division_id])
end
- it 'should contain child keys for polymorphic belongs to associations' do
+ it "should contain child keys for polymorphic belongs to associations" do
expect(RailsAdmin.config(Comment).fields.find{ |f| f.name == :commentable }.children_fields).to match_array POLYMORPHIC_CHILDREN
end
@@ -51,26 +51,26 @@ class CommentReversed < Tableless
expect(RailsAdmin.config(CommentReversed).fields.map{|f| f.name.to_s}.select{|f| /^comment/ =~ f}).to match_array ['commentable'].concat(POLYMORPHIC_CHILDREN.map(&:to_s))
end
- context 'of a Paperclip installation' do
- it 'should be a _file_name field' do
+ context "of a Paperclip installation" do
+ it "should be a _file_name field" do
expect(RailsAdmin.config(FieldTest).fields.find{ |f| f.name == :paperclip_asset }.children_fields.include?(:paperclip_asset_file_name)).to be_true
end
- it 'should be hidden, not filterable' do
+ it "should be hidden, not filterable" do
f = RailsAdmin.config(FieldTest).fields.find{ |f| f.name == :paperclip_asset_file_name }
expect(f.hidden?).to be_true
expect(f.filterable?).to be_false
end
end
- context 'of a Dragonfly installation' do
- it 'should be a _name field and _uid field' do
+ context "of a Dragonfly installation" do
+ it "should be a _name field and _uid field" do
expect(RailsAdmin.config(FieldTest).fields.find{ |f| f.name == :dragonfly_asset }.children_fields).to eq([:dragonfly_asset_name, :dragonfly_asset_uid])
end
end
- context 'of a Carrierwave installation' do
- it 'should be the parent field itself' do
+ context "of a Carrierwave installation" do
+ it "should be the parent field itself" do
expect(RailsAdmin.config(FieldTest).fields.find{ |f| f.name == :carrierwave_asset }.children_fields).to eq([:carrierwave_asset])
expect(RailsAdmin.config(FieldTest).fields.find{ |f| f.name == :carrierwave_asset }.hidden?).to be_false
end
@@ -78,7 +78,7 @@ class CommentReversed < Tableless
end
describe "#html_default_value" do
- it 'should be default_value for new records when value is nil' do
+ it "should be default_value for new records when value is nil" do
RailsAdmin.config Team do
list do
field :name do
@@ -97,7 +97,7 @@ class CommentReversed < Tableless
end
describe "#default_value" do
- it 'should be nil by default' do
+ it "should be nil by default" do
expect(RailsAdmin.config('Team').list.fields.find{|f| f.name == :name}.default_value).to be_nil
end
end
@@ -146,8 +146,8 @@ class CommentReversed < Tableless
end
end
- describe '#searchable_columns' do
- describe 'for belongs_to fields' do
+ describe "#searchable_columns" do
+ describe "for belongs_to fields" do
it "should find label method on the opposite side for belongs_to associations by default" do
expect(RailsAdmin.config(Team).fields.find{|f| f.name == :division}.searchable_columns.map{|c| c[:column]}).to eq(["divisions.name", "teams.division_id"])
end
@@ -180,14 +180,14 @@ class CommentReversed < Tableless
end
end
- describe 'for basic type fields' do
+ describe "for basic type fields" do
- it 'should use base table and find correct column type' do
+ it "should use base table and find correct column type" do
expect(RailsAdmin.config(FieldTest).fields.find{|f| f.name == :text_field}.searchable_columns).to eq([{:column=>"field_tests.text_field", :type=>:text}])
expect(RailsAdmin.config(FieldTest).fields.find{|f| f.name == :integer_field}.searchable_columns).to eq([{:column=>"field_tests.integer_field", :type=>:integer}])
end
- it 'should be customizable to another field on the same table' do
+ it "should be customizable to another field on the same table" do
RailsAdmin.config(FieldTest) do
field :time_field do
searchable :date_field
@@ -196,7 +196,7 @@ class CommentReversed < Tableless
expect(RailsAdmin.config(FieldTest).fields.find{|f| f.name == :time_field}.searchable_columns).to eq([{:column=>"field_tests.date_field", :type=>:date}])
end
- it 'should be customizable to another field on another table with :table_name' do
+ it "should be customizable to another field on another table with :table_name" do
RailsAdmin.config(FieldTest) do
field :string_field do
searchable :nested_field_tests => :title
@@ -205,7 +205,7 @@ class CommentReversed < Tableless
expect(RailsAdmin.config(FieldTest).fields.find{|f| f.name == :string_field}.searchable_columns).to eq([{:column=>"nested_field_tests.title", :type=>:string}])
end
- it 'should be customizable to another field on another model with ModelClass' do
+ it "should be customizable to another field on another model with ModelClass" do
RailsAdmin.config(FieldTest) do
field :string_field do
searchable NestedFieldTest => :title
@@ -215,16 +215,16 @@ class CommentReversed < Tableless
end
end
- describe 'for mapped fields' do
- it 'of paperclip should find the underlying column on the base table' do
+ describe "for mapped fields" do
+ it "of paperclip should find the underlying column on the base table" do
expect(RailsAdmin.config(FieldTest).fields.find{|f| f.name == :paperclip_asset}.searchable_columns.map{|c| c[:column]}).to eq(["field_tests.paperclip_asset_file_name"])
end
- it 'of dragonfly should find the underlying column on the base table' do
+ it "of dragonfly should find the underlying column on the base table" do
expect(RailsAdmin.config(FieldTest).fields.find{|f| f.name == :dragonfly_asset}.searchable_columns.map{|c| c[:column]}).to eq(["field_tests.dragonfly_asset_name"])
end
- it 'of carrierwave should find the underlying column on the base table' do
+ it "of carrierwave should find the underlying column on the base table" do
expect(RailsAdmin.config(FieldTest).fields.find{|f| f.name == :carrierwave_asset}.searchable_columns.map{|c| c[:column]}).to eq(["field_tests.carrierwave_asset"])
end
end
@@ -232,7 +232,7 @@ class CommentReversed < Tableless
describe "#searchable and #sortable" do
- it 'should be false if column is virtual, true otherwise' do
+ it "should be false if column is virtual, true otherwise" do
RailsAdmin.config League do
field :virtual_column
field :name
@@ -244,18 +244,18 @@ class CommentReversed < Tableless
expect(RailsAdmin.config('League').export.fields.find{ |f| f.name == :name }.searchable).to be_true
end
- context 'of a virtual field with children fields' do
- it 'of paperclip should target the first children field' do
+ context "of a virtual field with children fields" do
+ it "of paperclip should target the first children field" do
expect(RailsAdmin.config(FieldTest).fields.find{ |f| f.name == :paperclip_asset }.searchable).to eq(:paperclip_asset_file_name)
expect(RailsAdmin.config(FieldTest).fields.find{ |f| f.name == :paperclip_asset }.sortable).to eq(:paperclip_asset_file_name)
end
- it 'of dragonfly should target the first children field' do
+ it "of dragonfly should target the first children field" do
expect(RailsAdmin.config(FieldTest).fields.find{ |f| f.name == :dragonfly_asset }.searchable).to eq(:dragonfly_asset_name)
expect(RailsAdmin.config(FieldTest).fields.find{ |f| f.name == :dragonfly_asset }.sortable).to eq(:dragonfly_asset_name)
end
- it 'of carrierwave should target the first children field' do
+ it "of carrierwave should target the first children field" do
expect(RailsAdmin.config(FieldTest).fields.find{ |f| f.name == :carrierwave_asset }.searchable).to eq(:carrierwave_asset)
expect(RailsAdmin.config(FieldTest).fields.find{ |f| f.name == :carrierwave_asset }.sortable).to eq(:carrierwave_asset)
end
@@ -263,7 +263,7 @@ class CommentReversed < Tableless
end
describe "#virtual?" do
- it 'should be true if column has no properties, false otherwise' do
+ it "should be true if column has no properties, false otherwise" do
RailsAdmin.config League do
field :virtual_column
field :name
@@ -338,19 +338,19 @@ class CommentReversed < Tableless
end
end
- describe '#active' do
- it 'is false by default' do
+ describe "#active" do
+ it "is false by default" do
expect(RailsAdmin.config(Team).field(:division).active?).to be_false
end
end
- describe '#associated_collection' do
- it 'returns [] when type is blank?' do
+ describe "#associated_collection" do
+ it "returns [] when type is blank?" do
expect(RailsAdmin.config(Comment).fields.find{|f|f.name == :commentable}.associated_collection('')).to be_empty
end
end
- describe '#visible?' do
+ describe "#visible?" do
it "should be false when fields have specific name " do
class FieldVisibilityTest < Tableless
column :id, :integer
@@ -371,12 +371,12 @@ class FieldVisibilityTest < Tableless
end
end
- describe '#editable?' do
+ describe "#editable?" do
before do
Moped.logger.stub!(:debug) if defined?(Moped)
end
- it 'should yell for non attr_accessible fields if config.yell_for_non_accessible_fields is true' do
+ it "should yell for non attr_accessible fields if config.yell_for_non_accessible_fields is true" do
RailsAdmin.config do |config|
config.yell_for_non_accessible_fields = true
config.model FieldTest do
@@ -388,7 +388,7 @@ class FieldVisibilityTest < Tableless
expect(editable).to be_false
end
- it 'should not yell for non attr_accessible fields if config.yell_for_non_accessible_fields is false' do
+ it "should not yell for non attr_accessible fields if config.yell_for_non_accessible_fields is false" do
RailsAdmin.config do |config|
config.yell_for_non_accessible_fields = false
config.model FieldTest do
View
4 spec/unit/config/sections_spec.rb
@@ -32,7 +32,7 @@
end
describe "DSL field inheritance" do
- it 'should be tested' do
+ it "should be tested" do
RailsAdmin.config do |config|
config.model Fan do
field :name do
@@ -75,7 +75,7 @@
end
describe "DSL group inheritance" do
- it 'should be tested' do
+ it "should be tested" do
RailsAdmin.config do |config|
config.model Team do
list do
View
16 spec/unit/config_spec.rb
@@ -4,27 +4,27 @@
describe ".included_models" do
- it 'should only use included models' do
+ it "should only use included models" do
RailsAdmin.config.included_models = [Team, League]
expect(RailsAdmin::AbstractModel.all.map(&:model)).to eq([League, Team]) # it gets sorted
end
- it 'should not restrict models if included_models is left empty' do
+ it "should not restrict models if included_models is left empty" do
RailsAdmin.config.included_models = []
expect(RailsAdmin::AbstractModel.all.map(&:model)).to include(Team, League)
end
- it 'should further remove excluded models (whitelist - blacklist)' do
+ it "should further remove excluded models (whitelist - blacklist)" do
RailsAdmin.config.excluded_models = [Team]
RailsAdmin.config.included_models = [Team, League]
expect(RailsAdmin::AbstractModel.all.map(&:model)).to eq([League])
end
- it 'should always exclude history', :active_record => true do
+ it "should always exclude history", :active_record => true do
expect(RailsAdmin::AbstractModel.all.map(&:model)).not_to include(RailsAdmin::History)
end
- it 'excluded? returns true for any model not on the list' do
+ it "excluded? returns true for any model not on the list" do
RailsAdmin.config.included_models = [Team, League]
team_config = RailsAdmin::AbstractModel.new('Team').config
@@ -225,8 +225,8 @@
end
end
- describe '.visible_models' do
- it 'passes controller bindings, find visible models, order them' do
+ describe ".visible_models" do
+ it "passes controller bindings, find visible models, order them" do
RailsAdmin.config do |config|
config.included_models = [Player, Fan, Comment, Team]
@@ -252,7 +252,7 @@
expect(RailsAdmin.config.visible_models(:controller => double(:_current_user => double(:role => :admin), :authorized? => true)).map(&:abstract_model).map(&:model)).to match_array [Fan, Comment]
end
- it 'hides unallowed models' do
+ it "hides unallowed models" do
RailsAdmin.config do |config|
config.included_models = [Comment]
end
Please sign in to comment.
Something went wrong with that request. Please try again.