From 68dba9f1fe7663d1aaffeccc8a4321af34ff7419 Mon Sep 17 00:00:00 2001 From: whatthewhat Date: Tue, 21 Jun 2011 23:41:42 +0400 Subject: [PATCH 01/15] added russian localization --- lib/active_admin/locales/ru.yml | 34 +++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 lib/active_admin/locales/ru.yml diff --git a/lib/active_admin/locales/ru.yml b/lib/active_admin/locales/ru.yml new file mode 100644 index 00000000000..50e58b136af --- /dev/null +++ b/lib/active_admin/locales/ru.yml @@ -0,0 +1,34 @@ +ru: + active_admin: + dashboard_welcome: "Добро пожаловать в Active Admin. Это стандартная страница управления сайтом. Чтобы добавить сюда что-нибудь загляните в 'app/admin/dashboards.rb'" + view: "Открыть" + edit: "Изменить" + delete: "Удалить" + delete_confirmation: "Вы уверены, что хотите удалить это?" + new_model: "Создать" + edit_model: "Изменить" + delete_model: "Удалить" + details: "Подробнее" + cancel: "Отмена" + empty: "Пусто" + previous: "Пред." + next: "След." + download: "Загрузка:" + has_many_new: "Добавить %{model}" + has_many_delete: "Удалить" + filter: "Фильтровать" + clear_filters: "Очистить" + search_field: "Искать по %{field}" + equal_to: "=" + greater_than: ">" + less_than: "<" + main_content: "Создайте %{model}#main_content для отображения содержимого." + logout: "Выйти" + sidebars: + filters: "Фильтры" + pagination: + empty: "%{model} не найдено" + one: "Результат: 1 %{model}" + one_page: "Результат: %{n} %{model}" + multiple: "Результат: %{model} %{from} - %{to} из %{total}" + any: "Любой" \ No newline at end of file From 68a7a8974fc392158a267f442aa766584c437f66 Mon Sep 17 00:00:00 2001 From: Greg Bell Date: Thu, 16 Jun 2011 23:41:01 +0800 Subject: [PATCH 02/15] Fixed format steps for latest cucumber --- features/step_definitions/format_steps.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/step_definitions/format_steps.rb b/features/step_definitions/format_steps.rb index 33502861bc3..90c8ebe2b78 100644 --- a/features/step_definitions/format_steps.rb +++ b/features/step_definitions/format_steps.rb @@ -3,7 +3,7 @@ end Then /^I should see a link to download "([^"]*)"$/ do |format_type| - Then %{I should see "#{format_type}" within "#index_footer a"} + page.should have_css("#index_footer a", :text => format_type) end # Check first rows of the displayed CSV. From 13a518ee3d0d7266b442ec2313cdc34dda082275 Mon Sep 17 00:00:00 2001 From: Greg Bell Date: Fri, 17 Jun 2011 00:38:30 +0800 Subject: [PATCH 03/15] All cukes passing with latest Cucumber and Capybara --- features/specifying_actions.feature | 1 - 1 file changed, 1 deletion(-) diff --git a/features/specifying_actions.feature b/features/specifying_actions.feature index 283e1db7c2e..ffc59bdeb65 100644 --- a/features/specifying_actions.feature +++ b/features/specifying_actions.feature @@ -2,7 +2,6 @@ Feature: Specifying Actions Specifying which actions to allow on my resource - @allow-rescue Scenario: Only creating the index action Given a configuration of: """ From 95cd9c426be3b652cdd82ae0a48439f8399af523 Mon Sep 17 00:00:00 2001 From: Matt Vague Date: Fri, 17 Jun 2011 06:52:11 +0800 Subject: [PATCH 04/15] Fixed issue with .paginated_collection_contents not clearing floats in FF --- lib/active_admin/stylesheets/active_admin.scss | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/active_admin/stylesheets/active_admin.scss b/lib/active_admin/stylesheets/active_admin.scss index 1a3f9b5f7fb..63b487b34d6 100644 --- a/lib/active_admin/stylesheets/active_admin.scss +++ b/lib/active_admin/stylesheets/active_admin.scss @@ -204,6 +204,10 @@ table { b { color: #5c6469; } } +.paginated_collection_contents { + clear: both; +} + .pagination { display: inline; font-size: 0.9; From 5273842c1b0c27a56dcfc5b715affc2bf9613269 Mon Sep 17 00:00:00 2001 From: Greg Bell Date: Wed, 22 Jun 2011 07:39:31 +0800 Subject: [PATCH 05/15] Fixed specs to reflect the actual Resource#resource_table_name implementation --- spec/unit/resource_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/unit/resource_spec.rb b/spec/unit/resource_spec.rb index 4ed35bc636d..e9468fb1bd7 100644 --- a/spec/unit/resource_spec.rb +++ b/spec/unit/resource_spec.rb @@ -53,11 +53,11 @@ module ::Mock; class Resource; end; end describe "#resource_table_name" do it "should return the resource's table name" do - config.resource_table_name[1..-1].should == 'categories' + config.resource_table_name.should == '"categories"' end context "when the :as option is given" do it "should return the resource's table name" do - config(:as => "My Category").resource_table_name[1..-1].should == 'categories' + config(:as => "My Category").resource_table_name.should == '"categories"' end end end From 88e4f9fab2cd1671e6cd85b5bcb236f7c5704074 Mon Sep 17 00:00:00 2001 From: Greg Bell Date: Wed, 22 Jun 2011 22:44:07 +0800 Subject: [PATCH 06/15] Removing a dead helper: TableHelper --- lib/active_admin/view_helpers.rb | 1 - lib/active_admin/view_helpers/table_helper.rb | 12 ------------ 2 files changed, 13 deletions(-) delete mode 100644 lib/active_admin/view_helpers/table_helper.rb diff --git a/lib/active_admin/view_helpers.rb b/lib/active_admin/view_helpers.rb index 733d9b328ba..8bb426d155f 100644 --- a/lib/active_admin/view_helpers.rb +++ b/lib/active_admin/view_helpers.rb @@ -13,7 +13,6 @@ module ViewHelpers include IconHelper include MethodOrProcHelper include SidebarHelper - include TableHelper include FormHelper include FilterFormHelper include TitleHelper diff --git a/lib/active_admin/view_helpers/table_helper.rb b/lib/active_admin/view_helpers/table_helper.rb deleted file mode 100644 index e2adef8d733..00000000000 --- a/lib/active_admin/view_helpers/table_helper.rb +++ /dev/null @@ -1,12 +0,0 @@ -module ActiveAdmin - module ViewHelpers - module TableHelper - - # Helper to render a table for a collection - def table_for(collection, options = {}, &block) - ActiveAdmin::TableBuilder.new(&block).to_html(self, collection, options) - end - - end - end -end From 5dc6ea1266632922a427623496a7c4020390ad98 Mon Sep 17 00:00:00 2001 From: Greg Bell Date: Thu, 23 Jun 2011 22:27:27 +0800 Subject: [PATCH 07/15] Added specs to ensure that CSS was being rendered correctly. --- spec/integration/stylesheets_spec.rb | 41 ++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 spec/integration/stylesheets_spec.rb diff --git a/spec/integration/stylesheets_spec.rb b/spec/integration/stylesheets_spec.rb new file mode 100644 index 00000000000..760a5cb3fae --- /dev/null +++ b/spec/integration/stylesheets_spec.rb @@ -0,0 +1,41 @@ +require 'spec_helper' + +describe "Stylesheets" do + if Rails.version[0..2] == '3.1' + require "sprockets" + context "when Rails 3.1.x" do + let(:css) do + assets = Rails.application.assets + assets.find_asset("active_admin.css") + end + it "should successfully render the scss stylesheets using sprockets" do + css.should_not be_nil + end + it "should not have any syntax errors" do + css.to_s.should_not include("Syntax error:") + end + end + end + + if Rails.version[0..2] == '3.0' + context "when Rails 3.0.x" do + let(:stylesheet_path) do + Rails.root + 'public/stylesheets/active_admin.css' + end + + before do + "rm #{stylesheet_path}" if File.exists?(stylesheet_path) + Sass::Plugin.force_update_stylesheets + end + + it "should render the scss stylesheets using SASS" do + File.exists?(stylesheet_path).should be_true + end + + it "should not have any syntax errors" do + css = File.read(stylesheet_path) + css.should_not include("Syntax error:") + end + end + end +end From 0bf3418506fe1105594fa66aeefa9d0eb10da3c6 Mon Sep 17 00:00:00 2001 From: Greg Bell Date: Sat, 25 Jun 2011 05:57:54 +0800 Subject: [PATCH 08/15] Removing travis-ci image from README --- README.rdoc | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.rdoc b/README.rdoc index 5a0c98f915e..c4fff55f285 100644 --- a/README.rdoc +++ b/README.rdoc @@ -4,8 +4,6 @@ Active Admin is a framework for creating administration style interfaces. It abstracts common business application patterns to make it simple for developers to implement beautiful and elegant interfaces with very little effort. -http://travis-ci.org/gregbell/active_admin.png - == Goals 1. Allow developers to quickly create gorgeous administration interfaces From 20506afccb4a2f9496e84be75aef4dccb598110a Mon Sep 17 00:00:00 2001 From: Greg Bell Date: Sat, 25 Jun 2011 23:30:56 +0800 Subject: [PATCH 09/15] Removed the usage of deprected class_inheritable_array from Callbacks --- lib/active_admin/callbacks.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/active_admin/callbacks.rb b/lib/active_admin/callbacks.rb index 5d66ce64f3b..be508a64729 100644 --- a/lib/active_admin/callbacks.rb +++ b/lib/active_admin/callbacks.rb @@ -58,12 +58,14 @@ module ClassMethods def define_active_admin_callbacks(*names) names.each do |name| [:before, :after].each do |type| - # Create an inheritable accessor array for the callbacks - class_inheritable_array "#{type}_#{name}_callbacks".to_sym - send("#{type}_#{name}_callbacks=".to_sym, []) # Define a method to set the callback class_eval(<<-EOS, __FILE__, __LINE__ + 1) + # def self.before_create_callbacks + def self.#{type}_#{name}_callbacks + @#{type}_#{name}_callbacks ||= [] + end + # def self.before_create def self.#{type}_#{name}(method = nil, &block) #{type}_#{name}_callbacks << (method || block) From 87dd4235ca5de0c83f4dc151c9a14d307165daad Mon Sep 17 00:00:00 2001 From: Greg Bell Date: Sun, 26 Jun 2011 00:15:52 +0800 Subject: [PATCH 10/15] Updated the ResourceController callback specs to be more forgiving --- spec/unit/resource_controller_spec.rb | 53 +++++++++++++++------------ 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/spec/unit/resource_controller_spec.rb b/spec/unit/resource_controller_spec.rb index 9247b135f07..c62c855a6ca 100644 --- a/spec/unit/resource_controller_spec.rb +++ b/spec/unit/resource_controller_spec.rb @@ -45,31 +45,36 @@ end end - ActiveAdmin.register Post do - after_build :call_after_build - before_save :call_before_save - after_save :call_after_save - before_create :call_before_create - after_create :call_after_create - before_update :call_before_update - after_update :call_after_update - before_destroy :call_before_destroy - after_destroy :call_after_destroy - end - - class Admin::PostsController < ActiveAdmin::ResourceController - def call_after_build(obj); end - def call_before_save(obj); end - def call_after_save(obj); end - def call_before_create(obj); end - def call_after_create(obj); end - def call_before_update(obj); end - def call_after_update(obj); end - def call_before_destroy(obj); end - def call_after_destroy(obj); end - end - describe "callbacks" do + let(:application){ ::ActiveAdmin::Application.new } + let(:namespace){ ActiveAdmin::Namespace.new(application, :admin) } + + before :all do + namespace.register Post do + after_build :call_after_build + before_save :call_before_save + after_save :call_after_save + before_create :call_before_create + after_create :call_after_create + before_update :call_before_update + after_update :call_after_update + before_destroy :call_before_destroy + after_destroy :call_after_destroy + + controller do + def call_after_build(obj); end + def call_before_save(obj); end + def call_after_save(obj); end + def call_before_create(obj); end + def call_after_create(obj); end + def call_before_update(obj); end + def call_after_update(obj); end + def call_before_destroy(obj); end + def call_after_destroy(obj); end + end + end + end + describe "performing create" do let(:controller){ Admin::PostsController.new } let(:resource){ mock("Resource", :save => true) } From a3cf7dc313e8c1bdcdcb2e1b2d7de4256f639b26 Mon Sep 17 00:00:00 2001 From: Greg Bell Date: Tue, 28 Jun 2011 21:22:12 +0800 Subject: [PATCH 11/15] Specs and cukes now detect the version of rails we're using --- features/support/env.rb | 4 +++- spec/spec_helper.rb | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/features/support/env.rb b/features/support/env.rb index aca32681748..1580857a13c 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -6,11 +6,13 @@ ENV['BUNDLE_GEMFILE'] = File.expand_path('../../../Gemfile', __FILE__) +require File.expand_path('../../../spec/support/detect_rails_version', __FILE__) +ENV["RAILS"] ||= detect_rails_version + require 'rubygems' require "bundler" Bundler.setup -ENV["RAILS"] ||= "3.0.0" ENV["RAILS_ENV"] ||= "cucumber" ENV['RAILS_ROOT'] = File.expand_path("../../../spec/rails/rails-#{ENV["RAILS"]}", __FILE__) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 3de6c00f692..feaa0510070 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -3,6 +3,9 @@ ENV['BUNDLE_GEMFILE'] = File.expand_path('../../Gemfile', __FILE__) +require 'detect_rails_version' +ENV['RAILS'] ||= detect_rails_version + require "bundler" Bundler.setup @@ -79,9 +82,7 @@ def mock_action_view(assigns = {}) end -ENV['RAILS'] ||= '3.0.0' ENV['RAILS_ENV'] = 'test' - ENV['RAILS_ROOT'] = File.expand_path("../rails/rails-#{ENV["RAILS"]}", __FILE__) # Create the test app if it doesn't exists From 1365102e5b0f1d9ee03aec98356449b23c5f6532 Mon Sep 17 00:00:00 2001 From: Greg Bell Date: Wed, 29 Jun 2011 21:43:55 +0800 Subject: [PATCH 12/15] Fixed STI models when parent is registered and editing child. Fixes #52 --- features/step_definitions/factory_steps.rb | 5 +++-- features/sti_resource.feature | 12 ++++++++++++ lib/active_admin/views/pages/edit.rb | 3 ++- lib/active_admin/views/pages/new.rb | 3 ++- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/features/step_definitions/factory_steps.rb b/features/step_definitions/factory_steps.rb index 3a215cda173..ac6be4930d7 100644 --- a/features/step_definitions/factory_steps.rb +++ b/features/step_definitions/factory_steps.rb @@ -22,7 +22,8 @@ Category.create! :name => name end -Given /^a user named "([^"]*)" exists$/ do |name| +Given /^a (user|publisher) named "([^"]*)" exists$/ do |type, name| first, last = name.split(" ") - User.create! :first_name => first, :last_name => last, :username => name + type = type.camelize.constantize + type.create! :first_name => first, :last_name => last, :username => name end diff --git a/features/sti_resource.feature b/features/sti_resource.feature index 4343739a86c..3c669c864f6 100644 --- a/features/sti_resource.feature +++ b/features/sti_resource.feature @@ -47,3 +47,15 @@ Feature: STI Resource When I follow "Delete User" Then I should see "User was successfully destroyed" + + Scenario: Update and delete a child STI when the parent is registered + Given a publisher named "Terry Fox" exists + And I am on the index page for users + When I follow "Edit" + And I fill in "First name" with "Joe" + And I press "Update Publisher" + Then I should see "Publisher was successfully updated" + And I should see "Joe" + + When I follow "Delete User" + Then I should see "Publisher was successfully destroyed" diff --git a/lib/active_admin/views/pages/edit.rb b/lib/active_admin/views/pages/edit.rb index 89a374ba020..a0afef47bf4 100644 --- a/lib/active_admin/views/pages/edit.rb +++ b/lib/active_admin/views/pages/edit.rb @@ -11,7 +11,8 @@ def main_content config = self.form_config.dup config.delete(:block) config.reverse_merge!({ - :url => resource_path(resource) + :url => resource_path(resource), + :as => active_admin_config.underscored_resource_name }) if form_config[:partial] diff --git a/lib/active_admin/views/pages/new.rb b/lib/active_admin/views/pages/new.rb index 213da496ff6..5daf7afe86c 100644 --- a/lib/active_admin/views/pages/new.rb +++ b/lib/active_admin/views/pages/new.rb @@ -11,7 +11,8 @@ def main_content config = self.form_config.dup config.delete(:block) config.reverse_merge!({ - :url => collection_path + :url => collection_path, + :as => active_admin_config.underscored_resource_name }) if form_config[:partial] From da17bd488216fed1e90c9351308ce295597cf6ab Mon Sep 17 00:00:00 2001 From: whatthewhat Date: Thu, 7 Jul 2011 12:17:27 +0400 Subject: [PATCH 13/15] russian localization update --- lib/active_admin/locales/ru.yml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/active_admin/locales/ru.yml b/lib/active_admin/locales/ru.yml index 50e58b136af..5a317b1ae06 100644 --- a/lib/active_admin/locales/ru.yml +++ b/lib/active_admin/locales/ru.yml @@ -1,6 +1,8 @@ -ru: +en: active_admin: - dashboard_welcome: "Добро пожаловать в Active Admin. Это стандартная страница управления сайтом. Чтобы добавить сюда что-нибудь загляните в 'app/admin/dashboards.rb'" + dashboard_welcome: + welcome: "Добро пожаловать в Active Admin. Это стандартная страница управления сайтом." + call_to_action: "Чтобы добавить сюда что-нибудь загляните в 'app/admin/dashboards.rb'" view: "Открыть" edit: "Изменить" delete: "Удалить" @@ -24,6 +26,8 @@ ru: less_than: "<" main_content: "Создайте %{model}#main_content для отображения содержимого." logout: "Выйти" + sidebars: + filters: "Filters" sidebars: filters: "Фильтры" pagination: @@ -31,4 +35,7 @@ ru: one: "Результат: 1 %{model}" one_page: "Результат: %{n} %{model}" multiple: "Результат: %{model} %{from} - %{to} из %{total}" - any: "Любой" \ No newline at end of file + any: "Любой" + blank_slate: + content: "Пока нет %{resource_name}." + link: "Создать" \ No newline at end of file From 38e8b99700adb1439b1135d4a61489c00e681f57 Mon Sep 17 00:00:00 2001 From: whatthewhat Date: Thu, 7 Jul 2011 12:24:16 +0400 Subject: [PATCH 14/15] russian localization update(oops) --- lib/active_admin/locales/ru.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/active_admin/locales/ru.yml b/lib/active_admin/locales/ru.yml index 5a317b1ae06..8b742bf8c9c 100644 --- a/lib/active_admin/locales/ru.yml +++ b/lib/active_admin/locales/ru.yml @@ -1,4 +1,4 @@ -en: +ru: active_admin: dashboard_welcome: welcome: "Добро пожаловать в Active Admin. Это стандартная страница управления сайтом." @@ -26,8 +26,6 @@ en: less_than: "<" main_content: "Создайте %{model}#main_content для отображения содержимого." logout: "Выйти" - sidebars: - filters: "Filters" sidebars: filters: "Фильтры" pagination: From a949fc4321a0553995e1da8f4a5b23062bda53a5 Mon Sep 17 00:00:00 2001 From: whatthewhat Date: Mon, 11 Jul 2011 16:50:21 +0400 Subject: [PATCH 15/15] update russian i18n --- lib/active_admin/locales/ru.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/active_admin/locales/ru.yml b/lib/active_admin/locales/ru.yml index 8b742bf8c9c..2e01e440445 100644 --- a/lib/active_admin/locales/ru.yml +++ b/lib/active_admin/locales/ru.yml @@ -1,5 +1,6 @@ ru: active_admin: + dashboard: Dashboard dashboard_welcome: welcome: "Добро пожаловать в Active Admin. Это стандартная страница управления сайтом." call_to_action: "Чтобы добавить сюда что-нибудь загляните в 'app/admin/dashboards.rb'"