activeadmin-xls 1.0.4 → 1.0.5

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5542c9ca3fb9ec53761a8f17c84d33590ac41fd4
4
- data.tar.gz: 262f8f4e6e8068e1f8e2fb41744c1695454a965c
3
+ metadata.gz: b3cefe4337bc929cc027541a8b378764fcee9c29
4
+ data.tar.gz: 6ece12827ba7c2e0b85772b357c368a29d973c51
5
5
  SHA512:
6
- metadata.gz: 0d13b40efc0caab8e86510fbec44a8d2c9f9eb196440a311a8a2d8113218782f2311d0afe23700ab1ca394a19f647c87c944f25da3e67e4123011b9fbec4b5a2
7
- data.tar.gz: 6b80baec72b523eda62d72975e3158026c76f37a3e0d1ad149264ce4331fa6a583752fa5d63679354c14812b1669b471d0066f2925ad1778e5d212b7295b90f8
6
+ metadata.gz: a505457094d423aad3857be11f8aaf26adafa48957678296019324c15736be6bc89c40be0b41e4e3ea79ed17d9abd205e4463937aca9f40618193bf7eb3e8de4
7
+ data.tar.gz: 689a4ae242134e3cc0e7d7729b539eadca9349bbd141431422b7f0a83b10be7b3f72012ec60c92019b036973b9debe6f3e0b9ef947d35f815a51bb2dffb9c4a2
@@ -0,0 +1 @@
1
+ .bundle/*
data/.gitignore CHANGED
@@ -8,3 +8,4 @@ doc
8
8
  .rbenv-version
9
9
  .ruby-version
10
10
  /Gemfile.lock
11
+ gemfiles/*.gemfile.lock
@@ -1,10 +1,17 @@
1
1
  # Changelog
2
2
 
3
- ## 1.0.2
3
+ ## 1.0.5
4
4
 
5
- ### Bug Fixes
5
+ ### Updates
6
6
 
7
- * Fixes undefined local variable or `method max_per_page` [#3][] by [@rewritten][]
7
+ * Fix #1 - Unnecessary database access
8
+ * Fix broken tests
9
+
10
+ ## 1.0.4
11
+
12
+ ### Updates
13
+
14
+ * Minor bug fixes / typo corrections
8
15
 
9
16
  ## 1.0.3
10
17
 
@@ -12,6 +19,12 @@
12
19
 
13
20
  * Move require rake from gemspec to lib/activeadmin-xls.rb [#4][] by [@ejaypcanaria][]
14
21
 
22
+ ## 1.0.2
23
+
24
+ ### Bug Fixes
25
+
26
+ * Fixes undefined local variable or `method max_per_page` [#3][] by [@rewritten][]
27
+
15
28
  <!--- Link List --->
16
29
  [#3]: https://github.com/thambley/activeadmin-xls/issues/3
17
30
  [#4]: https://github.com/thambley/activeadmin-xls/pull/4
data/Gemfile CHANGED
@@ -1,30 +1,17 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'activeadmin', '~> 1.0'
4
3
  gem 'spreadsheet', '~> 1.1', '>= 1.1.4'
5
4
 
6
5
  group :development, :test do
7
- gem 'haml', require: false
8
6
  gem 'rails-i18n' # Gives us default i18n for many languages
9
- gem 'rdiscount' # For yard
10
- gem 'sprockets'
11
7
  gem 'sqlite3'
12
8
  gem 'yard'
13
9
  end
14
10
 
15
11
  group :test do
16
- gem 'capybara'
17
12
  gem 'cucumber-rails', require: false
18
13
  gem 'database_cleaner'
19
- gem 'guard-coffeescript'
20
- gem 'guard-rspec'
21
- gem 'inherited_resources'
22
- gem 'jasmine'
23
- gem 'jslint_on_rails', '~> 1.0.6'
24
- gem 'launchy'
25
- gem 'rspec-mocks'
26
- gem 'rspec-rails'
27
- gem 'sass-rails'
28
- gem 'shoulda-matchers', '1.0.0'
14
+ gem 'rspec-mocks', '~> 3.7'
15
+ gem 'rspec-rails', '~> 3.7'
29
16
  gem 'simplecov', require: false
30
17
  end
data/README.md CHANGED
@@ -113,15 +113,35 @@ end
113
113
  ## Specs
114
114
 
115
115
  Running specs for this gem requires that you construct a rails application.
116
- To execute the specs, navigate to the gem directory,
117
- run bundle install and run these to rake tasks:
116
+
117
+ To execute the specs, navigate to the gem directory, run bundle install and run these to rake tasks:
118
+
119
+ ### Rails 3.2
120
+
121
+ ```text
122
+ bundle install --gemfile=gemfiles/rails_32.gemfile
123
+ ```
124
+
125
+ ```text
126
+ BUNDLE_GEMFILE=gemfiles/rails_32.gemfile bundle exec rake setup
127
+ ```
128
+
129
+ ```text
130
+ BUNDLE_GEMFILE=gemfiles/rails_32.gemfile bundle exec rake
131
+ ```
132
+
133
+ ### Rails 4.2
134
+
135
+ ```text
136
+ bundle install --gemfile=gemfiles/rails_42.gemfile
137
+ ```
118
138
 
119
139
  ```text
120
- bundle exec rake setup
140
+ BUNDLE_GEMFILE=gemfiles/rails_42.gemfile bundle exec rake setup
121
141
  ```
122
142
 
123
143
  ```text
124
- bundle exec rake
144
+ BUNDLE_GEMFILE=gemfiles/rails_42.gemfile bundle exec rake
125
145
  ```
126
146
 
127
147
  ## Copyright and License
data/Rakefile CHANGED
@@ -1,23 +1,23 @@
1
1
  #!/usr/bin/env rake
2
- require "activeadmin"
3
- require "rspec/core/rake_task"
2
+ require 'rspec/core/rake_task'
4
3
 
5
- desc "Creates a test rails app for the specs to run against"
4
+ desc 'Creates a test rails app for the specs to run against'
6
5
  task :setup do
7
6
  require 'rails/version'
8
- system("mkdir spec/rails") unless File.exists?("spec/rails")
7
+ system('mkdir spec/rails') unless File.exist?('spec/rails')
8
+ puts "system \"bundle exec rails new spec/rails/rails-#{Rails::VERSION::STRING} -m spec/support/rails_template_with_data.rb\""
9
9
  system "bundle exec rails new spec/rails/rails-#{Rails::VERSION::STRING} -m spec/support/rails_template_with_data.rb"
10
10
  end
11
11
 
12
12
  RSpec::Core::RakeTask.new
13
- task :default => :spec
14
- task :test => :spec
13
+ task default: :spec
14
+ task test: :spec
15
15
 
16
- desc "build the gem"
16
+ desc 'build the gem'
17
17
  task :build do
18
- system "gem build activeadmin-xls.gemspec"
18
+ system 'gem build activeadmin-xls.gemspec'
19
19
  end
20
- desc "build and release the gem"
21
- task :release => :build do
20
+ desc 'build and release the gem'
21
+ task release: :build do
22
22
  system "gem push activeadmin-xls-#{ActiveAdmin::Xls::VERSION}.gem"
23
23
  end
@@ -15,9 +15,11 @@ Gem::Specification.new do |s|
15
15
  s.description = <<-DESC
16
16
  This gem provides excel/xls downloads for resources in Active Admin.
17
17
  DESC
18
- s.files = `git ls-files`.split("\n").sort
19
- s.test_files = `git ls-files -- {spec}/*`.split("\n")
20
- s.test_files = Dir.glob('{spec/**/*}')
18
+
19
+ git_tracked_files = `git ls-files`.split("\n").sort
20
+ gem_ignored_files = `git ls-files -i -X .gemignore`.split("\n")
21
+
22
+ s.files = git_tracked_files - gem_ignored_files
21
23
 
22
24
  s.add_runtime_dependency 'activeadmin', '>= 0.6.6', '< 2'
23
25
  s.add_runtime_dependency 'spreadsheet', '~> 1.0'
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env ruby
2
+ source 'https://rubygems.org'
3
+
4
+ ruby_major_version = RUBY_VERSION.split('.')[0].to_i
5
+ ruby_minor_version = RUBY_VERSION.split('.')[1].to_i
6
+
7
+ eval_gemfile(File.expand_path(File.join('..', 'Gemfile'), __dir__))
8
+
9
+ gem 'rails', '3.2.22.5'
10
+
11
+ gem 'activeadmin', '0.6.6'
12
+
13
+ group :assets do
14
+ gem 'coffee-rails', '~> 3.2.1'
15
+ gem 'sass-rails', '~> 3.2.3'
16
+
17
+ # See https://github.com/sstephenson/execjs#readme for more supported runtimes
18
+ # gem 'therubyracer', :platforms => :ruby
19
+
20
+ gem 'uglifier', '>= 1.0.3'
21
+ end
22
+
23
+ group :test do
24
+ gem 'shoulda-matchers', '~> 2.8.0'
25
+ if ruby_major_version > 2 || (ruby_major_version == 2 && ruby_minor_version > 1)
26
+ gem 'test-unit', '~> 3.0'
27
+ end
28
+ end
29
+
30
+ gemspec path: "../"
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env ruby
2
+ source 'https://rubygems.org'
3
+
4
+ ruby_major_version = RUBY_VERSION.split('.')[0].to_i
5
+ ruby_minor_version = RUBY_VERSION.split('.')[1].to_i
6
+
7
+ eval_gemfile(File.expand_path(File.join('..', 'Gemfile'), __dir__))
8
+
9
+ gem 'activeadmin', '1.0.0'
10
+ gem 'devise', '~> 4.2'
11
+ gem 'rails', '4.2.10'
12
+ gem 'turbolinks', '~> 5.0.0'
13
+ gem 'tzinfo-data'
14
+
15
+ group :test do
16
+ gem 'shoulda-matchers', '~> 3.1'
17
+ if ruby_major_version > 2 || (ruby_major_version == 2 && ruby_minor_version > 1)
18
+ gem 'test-unit', '~> 3.0'
19
+ end
20
+ end
21
+
22
+ gemspec path: "../"
@@ -29,7 +29,10 @@ module ActiveAdmin
29
29
  # @see ActiveAdmin::Axlsx::DSL
30
30
  def initialize(resource_class, options = {}, &block)
31
31
  @skip_header = false
32
- @columns = resource_columns(resource_class)
32
+ @resource_class = resource_class
33
+ @columns = []
34
+ @columns_loaded = false
35
+ @column_updates = []
33
36
  parse_options options
34
37
  instance_eval(&block) if block_given?
35
38
  end
@@ -60,9 +63,7 @@ module ActiveAdmin
60
63
 
61
64
  # The scope to use when looking up column names to generate the
62
65
  # report header
63
- def i18n_scope
64
- @i18n_scope ||= nil
65
- end
66
+ attr_reader :i18n_scope
66
67
 
67
68
  # This is the I18n scope that will be used when looking up your
68
69
  # colum names in the current I18n locale.
@@ -83,7 +84,12 @@ module ActiveAdmin
83
84
  end
84
85
 
85
86
  # The columns this builder will be serializing
86
- attr_reader :columns
87
+ def columns
88
+ # execute each update from @column_updates
89
+ # set @columns_loaded = true
90
+ load_columns unless @columns_loaded
91
+ @columns
92
+ end
87
93
 
88
94
  # The collection we are serializing.
89
95
  # @note This is only available after serialize has been called,
@@ -94,34 +100,50 @@ module ActiveAdmin
94
100
  # only render specific columns. To remove specific columns use
95
101
  # ignore_column.
96
102
  def clear_columns
103
+ @columns_loaded = true
104
+ @column_updates = []
105
+
97
106
  @columns = []
98
107
  end
99
108
 
100
109
  # Clears the default columns array so you can whitelist only the columns
101
110
  # you want to export
102
- def whitelist
103
- @columns = []
104
- end
111
+ alias whitelist clear_columns
105
112
 
106
113
  # Add a column
107
114
  # @param [Symbol] name The name of the column.
108
115
  # @param [Proc] block A block of code that is executed on the resource
109
116
  # when generating row data for this column.
110
117
  def column(name, &block)
111
- @columns << Column.new(name, block)
118
+ if @columns_loaded
119
+ columns << Column.new(name, block)
120
+ else
121
+ column_lambda = lambda do
122
+ column(name, &block)
123
+ end
124
+ @column_updates << column_lambda
125
+ end
112
126
  end
113
127
 
114
128
  # removes columns by name
115
129
  # each column_name should be a symbol
116
130
  def delete_columns(*column_names)
117
- @columns.delete_if { |column| column_names.include?(column.name) }
131
+ if @columns_loaded
132
+ columns.delete_if { |column| column_names.include?(column.name) }
133
+ else
134
+ delete_lambda = lambda do
135
+ delete_columns(*column_names)
136
+ end
137
+ @column_updates << delete_lambda
138
+ end
118
139
  end
119
140
 
120
141
  # Serializes the collection provided
121
142
  # @return [Spreadsheet::Workbook]
122
- def serialize(collection, view_context)
143
+ def serialize(collection, view_context = nil)
123
144
  @collection = collection
124
145
  @view_context = view_context
146
+ load_columns unless @columns_loaded
125
147
  apply_filter @before_filter
126
148
  export_collection(collection)
127
149
  apply_filter @after_filter
@@ -145,6 +167,15 @@ module ActiveAdmin
145
167
 
146
168
  private
147
169
 
170
+ def load_columns
171
+ return if @columns_loaded
172
+ @columns = resource_columns(@resource_class)
173
+ @columns_loaded = true
174
+ @column_updates.each(&:call)
175
+ @column_updates = []
176
+ columns
177
+ end
178
+
148
179
  def to_stream
149
180
  stream = StringIO.new('')
150
181
  book.write stream
@@ -158,11 +189,11 @@ module ActiveAdmin
158
189
 
159
190
  def export_collection(collection)
160
191
  return if columns.none?
161
- row_index = 0
192
+ row_index = sheet.dimensions[1]
162
193
 
163
194
  unless @skip_header
164
- header_row(collection)
165
- row_index = 1
195
+ header_row(sheet.row(row_index), collection)
196
+ row_index += 1
166
197
  end
167
198
 
168
199
  collection.each do |resource|
@@ -173,14 +204,13 @@ module ActiveAdmin
173
204
 
174
205
  # tranform column names into array of localized strings
175
206
  # @return [Array]
176
- def header_row(collection)
177
- row = sheet.row(0)
207
+ def header_row(row, collection)
178
208
  apply_format_to_row(row, create_format(header_format))
179
209
  fill_row(row, header_data_for(collection))
180
210
  end
181
211
 
182
212
  def header_data_for(collection)
183
- resource = collection.first
213
+ resource = collection.first || @resource_class.new
184
214
  columns.map do |column|
185
215
  column.localized_name(i18n_scope) if in_scope(resource, column)
186
216
  end.compact
@@ -10,15 +10,22 @@ module ActiveAdmin
10
10
 
11
11
  def index_with_xls
12
12
  index_without_xls do |format|
13
- yield format if block_given?
14
-
15
13
  format.xls do
16
- xls = active_admin_config.xls_builder.serialize(collection,
17
- view_context)
14
+ xls_collection = if method(:find_collection).arity.zero?
15
+ collection
16
+ else
17
+ find_collection except: :pagination
18
+ end
19
+ xls = active_admin_config.xls_builder.serialize(
20
+ xls_collection,
21
+ view_context
22
+ )
18
23
  send_data(xls,
19
24
  filename: xls_filename,
20
25
  type: Mime::Type.lookup_by_extension(:xls))
21
26
  end
27
+
28
+ yield(format) if block_given?
22
29
  end
23
30
  end
24
31
 
@@ -1,5 +1,5 @@
1
1
  module ActiveAdmin
2
2
  module Xls
3
- VERSION = '1.0.4'.freeze
3
+ VERSION = '1.0.5'.freeze
4
4
  end
5
5
  end
@@ -1,25 +1,38 @@
1
1
  require 'simplecov'
2
2
  SimpleCov.start do
3
- add_filter "/rails/"
3
+ add_filter '/rails/'
4
+ add_filter '/spec/'
4
5
  end
5
6
 
7
+ ENV['RAILS_ENV'] = 'test'
8
+
6
9
  # prepare ENV for rails
7
10
  require 'rails'
8
- ENV['RAILS_ROOT'] = File.expand_path("../rails/rails-#{Rails::VERSION::STRING}", __FILE__)
11
+ ENV['RAILS_ROOT'] = File.expand_path(
12
+ "../rails/rails-#{Rails::VERSION::STRING}",
13
+ __FILE__
14
+ )
9
15
 
10
16
  # ensure testing application is in place
11
- unless File.exists?(ENV['RAILS_ROOT'])
12
- puts "Please run bundle exec rake setup before running the specs."
17
+ unless File.exist?(ENV['RAILS_ROOT'])
18
+ puts 'Please run bundle exec rake setup before running the specs.'
13
19
  exit
14
20
  end
15
21
 
16
22
  # load up activeadmin and activeadmin-xls
23
+ require 'active_record'
24
+ require 'active_admin'
25
+ require 'devise'
17
26
  require 'activeadmin-xls'
18
- ActiveAdmin.application.load_paths = [ENV['RAILS_ROOT'] + "/app/admin"]
27
+ ActiveAdmin.application.load_paths = [ENV['RAILS_ROOT'] + '/app/admin']
28
+
19
29
  # start up rails
20
30
  require ENV['RAILS_ROOT'] + '/config/environment'
21
31
 
22
32
  # and finally,here's rspec
23
33
  require 'rspec/rails'
34
+
35
+ # Disabling authentication in specs so that we don't have to worry about
36
+ # it allover the place
24
37
  ActiveAdmin.application.authentication_method = false
25
38
  ActiveAdmin.application.current_user_method = false
@@ -1,73 +1,102 @@
1
1
  # Rails template to build the sample app for specs
2
2
 
3
3
  # Create a cucumber database and environment
4
- copy_file File.expand_path('../templates/cucumber.rb', __FILE__), "config/environments/cucumber.rb"
5
- copy_file File.expand_path('../templates/cucumber_with_reloading.rb', __FILE__), "config/environments/cucumber_with_reloading.rb"
4
+ copy_file File.expand_path('../templates/cucumber.rb', __FILE__),
5
+ 'config/environments/cucumber.rb'
6
+ copy_file File.expand_path('../templates/cucumber_with_reloading.rb', __FILE__),
7
+ 'config/environments/cucumber_with_reloading.rb'
6
8
 
7
9
  gsub_file 'config/database.yml', /^test:.*\n/, "test: &test\n"
8
- gsub_file 'config/database.yml', /\z/, "\ncucumber:\n <<: *test\n database: db/cucumber.sqlite3"
9
- gsub_file 'config/database.yml', /\z/, "\ncucumber_with_reloading:\n <<: *test\n database: db/cucumber.sqlite3"
10
+ gsub_file 'config/database.yml',
11
+ /\z/,
12
+ "\ncucumber:\n <<: *test\n database: db/cucumber.sqlite3"
13
+ gsub_file 'config/database.yml',
14
+ /\z/,
15
+ "\ncucumber_with_reloading:\n <<: *test\n database: db/cucumber.sqlite3"
10
16
 
11
17
  # Generate some test models
12
- generate :model, "post title:string body:text published_at:datetime author_id:integer category_id:integer"
13
- inject_into_file 'app/models/post.rb', " belongs_to :author, :class_name => 'User'\n belongs_to :category\n accepts_nested_attributes_for :author\n", :after => "class Post < ActiveRecord::Base\n"
18
+ generate :model, 'post title:string body:text published_at:datetime author_id:integer category_id:integer'
19
+ inject_into_file 'app/models/post.rb', " belongs_to :author, class_name: 'User'\n belongs_to :category\n accepts_nested_attributes_for :author\n", after: "class Post < ActiveRecord::Base\n"
14
20
  # Rails 3.2.3 model generator declare attr_accessible
15
- inject_into_file 'app/models/post.rb', " attr_accessible :author\n", :before => "end" if Rails::VERSION::STRING >= '3.2.3'
16
- generate :model, "user type:string first_name:string last_name:string username:string age:integer"
17
- inject_into_file 'app/models/user.rb', " has_many :posts, :foreign_key => 'author_id'\n", :after => "class User < ActiveRecord::Base\n"
18
- generate :model, "publisher --migration=false --parent=User"
21
+ if Rails::VERSION::MAJOR == 3
22
+ inject_into_file 'app/models/post.rb',
23
+ " attr_accessible :author\n",
24
+ before: 'end'
25
+ end
26
+ generate :model, 'user type:string first_name:string last_name:string username:string age:integer'
27
+ inject_into_file 'app/models/user.rb', " has_many :posts, foreign_key: 'author_id'\n", after: "class User < ActiveRecord::Base\n"
28
+ generate :model, 'publisher --migration=false --parent=User'
19
29
  generate :model, 'category name:string description:text'
20
- inject_into_file 'app/models/category.rb', " has_many :posts\n accepts_nested_attributes_for :posts\n", :after => "class Category < ActiveRecord::Base\n"
30
+ inject_into_file 'app/models/category.rb', " has_many :posts\n accepts_nested_attributes_for :posts\n", after: "class Category < ActiveRecord::Base\n"
21
31
  generate :model, 'store name:string'
22
32
 
23
33
  # Generate a model with string ids
24
- generate :model, "tag name:string"
25
- gsub_file(Dir['db/migrate/*_create_tags.rb'][0], /\:tags\sdo\s.*/, ":tags, :id => false, :primary_key => :id do |t|\n\t\t\tt.string :id\n" )
26
- id_model_setup = <<-EOF
34
+ generate :model, 'tag name:string'
35
+ gsub_file(Dir['db/migrate/*_create_tags.rb'][0], /\:tags\sdo\s.*/, ":tags, id: false, primary_key: :id do |t|\n\t\t\tt.string :id\n" )
36
+ id_model_setup = <<-MODEL
27
37
  self.primary_key = :id
28
38
  before_create :set_id
29
-
39
+
30
40
  private
31
41
  def set_id
32
- self.id = 8.times.inject("") { |s,e| s << (i = Kernel.rand(62); i += ((i < 10) ? 48 : ((i < 36) ? 55 : 61 ))).chr }
42
+ self.id = 8.times.inject('') { |s,e| s << (i = Kernel.rand(62); i += ((i < 10) ? 48 : ((i < 36) ? 55 : 61 ))).chr }
33
43
  end
34
- EOF
35
- inject_into_file 'app/models/tag.rb', id_model_setup, :after => "class Tag < ActiveRecord::Base\n"
44
+ MODEL
45
+
46
+ inject_into_file 'app/models/tag.rb',
47
+ id_model_setup,
48
+ after: "class Tag < ActiveRecord::Base\n"
36
49
 
37
- if Rails::VERSION::MAJOR == 3 && Rails::VERSION::MINOR == 1 #Rails 3.1 Gotcha
38
- gsub_file 'app/models/tag.rb', /self\.primary_key.*$/, "define_attr_method :primary_key, :id"
50
+ if Rails::VERSION::MAJOR == 3 && Rails::VERSION::MINOR == 1 # Rails 3.1 Gotcha
51
+ gsub_file 'app/models/tag.rb',
52
+ /self\.primary_key.*$/,
53
+ 'define_attr_method :primary_key, :id'
39
54
  end
40
55
 
41
56
  # Configure default_url_options in test environment
42
- inject_into_file "config/environments/test.rb", " config.action_mailer.default_url_options = { :host => 'example.com' }\n", :after => "config.cache_classes = true\n"
57
+ inject_into_file 'config/environments/test.rb',
58
+ " config.action_mailer.default_url_options = { host: 'example.com' }\n",
59
+ after: "config.cache_classes = true\n"
43
60
 
61
+ puts File.expand_path('../../../lib/activeadmin-xls', __FILE__)
44
62
  # Add our local Active Admin to the load path
45
- inject_into_file "config/environment.rb", "\nrequire \"activeadmin-xls\"\n", :after => "require File.expand_path('../application', __FILE__)"
63
+ inject_into_file 'config/environment.rb',
64
+ "\nrequire \"#{File.expand_path('../../../lib/activeadmin-xls', __FILE__)}\"\n",
65
+ after: "require File.expand_path('../application', __FILE__)"
46
66
 
47
67
  # Add some translations
48
- append_file "config/locales/en.yml", File.read(File.expand_path('../templates/en.yml', __FILE__))
68
+ append_file 'config/locales/en.yml',
69
+ File.read(File.expand_path('../templates/en.yml', __FILE__))
49
70
 
50
71
  # Add predefined admin resources
51
- directory File.expand_path('../templates/admin', __FILE__), "app/admin"
72
+ directory File.expand_path('../templates/admin', __FILE__), 'app/admin'
52
73
 
53
- run "rm Gemfile"
54
- run "rm -r test"
55
- run "rm -r spec"
74
+ run 'rm Gemfile'
75
+ run 'rm -r test'
76
+ run 'rm -r spec'
56
77
 
57
78
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
58
79
 
59
- # we need this routing path, named "logout_path", for testing
60
- route <<-EOS
80
+ if Rails::VERSION::MAJOR == 3
81
+ # we need this routing path, named "logout_path", for testing
82
+ route <<-ROUTE
61
83
  devise_scope :user do
62
- match '/admin/logout' => 'active_admin/devise/sessions#destroy', :as => :logout
84
+ match '/admin/logout' => 'active_admin/devise/sessions#destroy', as: :logout
63
85
  end
64
- EOS
86
+ ROUTE
87
+ end
65
88
 
66
89
  generate :'active_admin:install'
67
90
 
91
+ if Rails::VERSION::MAJOR > 3
92
+ inject_into_file 'config/initializers/active_admin.rb',
93
+ " config.download_links = %i[csv xml json xls]\n",
94
+ after: " # == Download Links\n"
95
+ end
96
+
68
97
  # Setup a root path for devise
69
- route "root :to => 'admin/dashboard#index'"
98
+ route "root to: 'admin/dashboard#index'"
70
99
 
71
- rake "db:migrate"
72
- rake "db:test:prepare"
73
- run "/usr/bin/env RAILS_ENV=cucumber rake db:migrate"
100
+ rake 'db:migrate'
101
+ rake 'db:test:prepare'
102
+ run '/usr/bin/env RAILS_ENV=cucumber rake db:migrate'
@@ -1,13 +1,13 @@
1
1
  # Use the default
2
- apply File.expand_path("../rails_template.rb", __FILE__)
2
+ apply File.expand_path('../rails_template.rb', __FILE__)
3
3
 
4
4
  # Register Active Admin controllers
5
- %w{ Post User Category }.each do |type|
5
+ %w[Post User Category].each do |type|
6
6
  generate :'active_admin:resource', type
7
7
  end
8
8
 
9
- scopes = <<-EOF
10
- scope :all, :default => true
9
+ scopes = <<-SCOPES
10
+ scope :all, default: true
11
11
 
12
12
  scope :drafts do |posts|
13
13
  posts.where(["published_at IS NULL"])
@@ -24,22 +24,25 @@ scopes = <<-EOF
24
24
  scope :my_posts do |posts|
25
25
  posts.where(:author_id => current_admin_user.id)
26
26
  end
27
+ SCOPES
27
28
 
28
- EOF
29
- inject_into_file 'app/admin/posts.rb', scopes , :after => "ActiveAdmin.register Post do\n"
29
+ inject_into_file 'app/admin/post.rb',
30
+ scopes,
31
+ after: "ActiveAdmin.register Post do\n"
30
32
 
31
33
  # Setup some default data
32
- append_file "db/seeds.rb", <<-EOF
33
- users = ["Jimi Hendrix", "Jimmy Page", "Yngwie Malmsteen", "Eric Clapton", "Kirk Hammett"].collect do |name|
34
+ append_file 'db/seeds.rb', <<-SEEDS
35
+
36
+ users = ['Jimi Hendrix', 'Jimmy Page', 'Yngwie Malmsteen', 'Eric Clapton', 'Kirk Hammett'].collect do |name|
34
37
  first, last = name.split(" ")
35
- User.create! :first_name => first,
36
- :last_name => last,
37
- :username => [first,last].join('-').downcase,
38
- :age => rand(80)
38
+ User.create! first_name: first,
39
+ last_name: last,
40
+ username: [first,last].join('-').downcase,
41
+ age: rand(80)
39
42
  end
40
43
 
41
- categories = ["Rock", "Pop Rock", "Alt-Country", "Blues", "Dub-Step"].collect do |name|
42
- Category.create! :name => name
44
+ categories = ['Rock', 'Pop Rock', 'Alt-Country', 'Blues', 'Dub-Step'].collect do |name|
45
+ Category.create! name: name
43
46
  end
44
47
 
45
48
  published_at_values = [Time.now.utc - 5.days, Time.now.utc - 1.day, nil, Time.now.utc + 3.days]
@@ -48,12 +51,12 @@ append_file "db/seeds.rb", <<-EOF
48
51
  user = users[i % users.size]
49
52
  cat = categories[i % categories.size]
50
53
  published_at = published_at_values[i % published_at_values.size]
51
- Post.create :title => "Blog Post \#{i}",
52
- :body => "Blog post \#{i} is written by \#{user.username} about \#{cat.name}",
53
- :category_id => cat.id,
54
- :published_at => published_at,
55
- :author => user
54
+ Post.create title: "Blog Post \#{i}",
55
+ body: "Blog post \#{i} is written by \#{user.username} about \#{cat.name}",
56
+ category_id: cat.id,
57
+ published_at: published_at,
58
+ author: user
56
59
  end
57
- EOF
60
+ SEEDS
58
61
 
59
62
  rake 'db:seed'
@@ -1,5 +1,5 @@
1
1
  # Sample translations used to test ActiveAdmin's I18n integration.
2
- axlsx:
2
+ xls:
3
3
  post:
4
4
  id: ID
5
5
  title: Title
@@ -19,30 +19,34 @@ describe ActiveAdmin::Views::PaginatedCollection do
19
19
 
20
20
  let(:view) do
21
21
  view = mock_action_view
22
- view.request.stub!(:query_parameters).and_return({:controller => 'admin/posts', :action => 'index', :page => '1'})
23
- view.controller.params = {:controller => 'admin/posts', :action => 'index'}
22
+ allow(view.request).to receive(:query_parameters) { { page: '1' } }
23
+ allow(view.request).to receive(:path_parameters) do
24
+ { controller: 'admin/posts', action: 'index' }
25
+ end
24
26
  view
25
27
  end
26
28
 
27
29
  # Helper to render paginated collections within an arbre context
28
30
  def paginated_collection(*args)
29
- render_arbre_component({:paginated_collection_args => args}, view) do
31
+ render_arbre_component({ paginated_collection_args: args }, view) do
30
32
  paginated_collection(*paginated_collection_args)
31
33
  end
32
34
  end
33
35
 
34
36
  let(:collection) do
35
- posts = [Post.new(:title => "First Post")]
37
+ posts = [Post.new(title: 'First Post')]
36
38
  Kaminari.paginate_array(posts).page(1).per(5)
37
39
  end
38
40
 
39
41
  let(:pagination) { paginated_collection(collection) }
40
42
 
41
43
  before do
42
- collection.stub!(:reorder) { collection }
44
+ allow(collection).to receive(:except) { collection } unless collection.respond_to? :except
45
+ allow(collection).to receive(:group_values) { [] } unless collection.respond_to? :group_values
46
+ allow(collection).to receive(:reorder) { collection }
43
47
  end
44
48
 
45
- it "renders the xls download link" do
46
- pagination.children.last.content.should match(/XLS/)
49
+ it 'renders the xls download link' do
50
+ expect(pagination.children.last.content).to match(/XLS/)
47
51
  end
48
52
  end
@@ -3,191 +3,190 @@ require 'spec_helper'
3
3
  module ActiveAdmin
4
4
  module Xls
5
5
  describe Builder do
6
-
7
6
  let(:builder) { Builder.new(Post) }
8
7
  let(:content_columns) { Post.content_columns }
9
8
 
10
9
  context 'the default builder' do
11
- subject { builder }
12
- its(:header_style) { should == { :bg_color => '00', :fg_color => 'FF', :sz => 12, :alignment => { :horizontal => :center } } }
13
- its(:i18n_scope) { should be_nil }
14
- its("columns.size") { should == content_columns.size + 1 }
10
+ it 'has no header style' do
11
+ expect(builder.header_style).to eq({})
12
+ end
13
+ it 'has no i18n scope' do
14
+ expect(builder.i18n_scope).to be_nil
15
+ end
16
+ it 'has default columns' do
17
+ expect(builder.columns.size).to eq(content_columns.size + 1)
18
+ end
15
19
  end
16
20
 
17
21
  context 'customizing a builder' do
18
22
  it 'deletes columns we tell it we dont want' do
19
23
  builder.delete_columns :id, :body
20
- builder.columns.size.should == content_columns.size - 1
24
+ expect(builder.columns.size).to eq(content_columns.size - 1)
21
25
  end
22
26
 
23
27
  it 'lets us say we dont want the header' do
24
28
  builder.skip_header
25
- builder.instance_values["skip_header"].should be_true
29
+ expect(builder.instance_values['skip_header']).to be_truthy
26
30
  end
27
31
 
28
32
  it 'lets us add custom columns' do
29
33
  builder.column(:hoge)
30
- builder.columns.size.should == content_columns.size + 2
34
+ expect(builder.columns.size).to eq(content_columns.size + 2)
31
35
  end
32
36
 
33
37
  it 'lets us clear all columns' do
34
38
  builder.clear_columns
35
- builder.columns.size.should == 0
39
+ expect(builder.columns.size).to eq(0)
36
40
  end
37
41
 
38
42
  context 'Using Procs for delayed content generation' do
39
-
40
- let(:post) { Post.new(:title => "Hot Dawg") }
43
+ let(:post) { Post.new(title: 'Hot Dawg') }
41
44
 
42
45
  before do
43
- builder.column(:hoge) { |resource| "#{resource.title} - with cheese" }
46
+ builder.column(:hoge) do |resource|
47
+ "#{resource.title} - with cheese"
48
+ end
44
49
  end
45
50
 
46
51
  it 'stores the block when defining a column for later execution.' do
47
- builder.columns.last.data.should be_a(Proc)
52
+ expect(builder.columns.last.data).to be_a(Proc)
48
53
  end
49
54
 
50
55
  it 'evaluates custom column blocks' do
51
- builder.columns.last.data.call(post).should == "Hot Dawg - with cheese"
56
+ expect(builder.columns.last.data.call(post)).to eq('Hot Dawg - with cheese')
52
57
  end
53
58
  end
54
59
  end
55
60
 
56
61
  context 'sheet generation without headers' do
57
- let!(:users) { [User.new(first_name: 'bob', last_name: 'nancy')] }
62
+ let!(:users) { [User.new(first_name: 'bob', last_name: 'nancy')] }
58
63
 
59
- let!(:posts) { [Post.new(title: 'bob', body: 'is a swell guy', author: users.first)] }
64
+ let!(:posts) { [Post.new(title: 'bob', body: 'is a swell guy', author: users.first)] }
60
65
 
61
- let!(:builder) {
62
- Builder.new(Post, header_style: { sz: 10, fg_color: "FF0000" }, i18n_scope: [:xls, :post]) do
66
+ let!(:builder) do
67
+ Builder.new(Post, header_format: { weight: :bold }, i18n_scope: %i[xls post]) do
63
68
  skip_header
64
69
  end
65
- }
70
+ end
66
71
 
67
72
  before do
68
- User.stub!(:all) { users }
69
- Post.stub!(:all) { posts }
70
- # disable clean up so we can get the package.
71
- builder.stub(:clean_up) { false }
72
- builder.serialize(Post.all)
73
- @package = builder.send(:package)
73
+ # disable clean up so we can get the book.
74
+ allow(builder).to receive(:clean_up) { false }
75
+ # @book = Spreadsheet.open(builder.serialize(posts))
76
+ builder.serialize(posts)
77
+ @book = builder.send(:book)
74
78
  @collection = builder.collection
75
79
  end
76
80
 
77
81
  it 'does not serialize the header' do
78
- not_header = @package.workbook.worksheets.first.rows.first
79
- not_header.cells.first.value.should_not == 'Title'
82
+ expect(@book.worksheets.first[0, 0]).not_to eq('Title')
80
83
  end
81
84
  end
82
85
 
83
86
  context 'whitelisted sheet generation' do
84
- let!(:users) { [User.new(first_name: 'bob', last_name: 'nancy')] }
87
+ let!(:users) { [User.new(first_name: 'bob', last_name: 'nancy')] }
85
88
 
86
- let!(:posts) { [Post.new(title: 'bob', body: 'is a swell guy', author: users.first)] }
89
+ let!(:posts) do
90
+ [Post.new(title: 'bob', body: 'is a swell guy', author: users.first)]
91
+ end
87
92
 
88
- let!(:builder) {
89
- Builder.new(Post, header_style: { sz: 10, fg_color: "FF0000" }, i18n_scope: [:xls, :post]) do
93
+ let!(:builder) do
94
+ Builder.new(Post, header_style: {}, i18n_scope: %i[xls post]) do
90
95
  skip_header
91
96
  whitelist
92
97
  column :title
93
98
  end
94
- }
99
+ end
95
100
 
96
101
  before do
97
- User.stub!(:all) { users }
98
- Post.stub!(:all) { posts }
99
- # disable clean up so we can get the package.
100
- builder.stub(:clean_up) { false }
102
+ allow(User).to receive(:all) { users }
103
+ allow(Post).to receive(:all) { posts }
104
+ # disable clean up so we can get the book.
105
+ allow(builder).to receive(:clean_up) { false }
101
106
  builder.serialize(Post.all)
102
- @package = builder.send(:package)
107
+ @book = builder.send(:book)
103
108
  @collection = builder.collection
104
109
  end
105
110
 
106
111
  it 'does not serialize the header' do
107
- sheet = @package.workbook.worksheets.first
108
- sheet.rows.first.cells.size.should == 1
109
- sheet.rows.first.cells.first.value.should == @collection.first.title
112
+ sheet = @book.worksheets.first
113
+ expect(sheet.column_count).to eq(1)
114
+ expect(sheet[0, 0]).to eq(@collection.first.title)
110
115
  end
111
116
  end
112
117
 
113
118
  context 'Sheet generation with a highly customized configuration.' do
114
-
115
- let!(:users) { [User.new(first_name: 'bob', last_name: 'nancy')] }
116
-
117
- let!(:posts) { [Post.new(title: 'bob', body: 'is a swell guy', author: users.first)] }
118
-
119
- let!(:builder) {
120
- Builder.new(Post, header_style: { sz: 10, fg_color: "FF0000" }, i18n_scope: [:xls, :post]) do
119
+ let!(:builder) do
120
+ Builder.new(Post, header_style: { size: 10, color: 'red' }, i18n_scope: %i[xls post]) do
121
121
  delete_columns :id, :created_at, :updated_at
122
- column(:author) { |resource| "#{resource.author.first_name} #{resource.author.last_name}" }
123
- after_filter { |sheet|
124
- sheet.add_row []
125
- sheet.add_row ['Author Name', 'Number of Posts']
126
- data = []
127
- labels = []
128
- User.all.each do |user|
129
- data << user.posts.size
130
- labels << "#{user.first_name} #{user.last_name}"
131
- sheet.add_row [labels.last, data.last]
132
- end
133
- chart_color = %w(88F700 279CAC B2A200 FD66A3 F20062 C8BA2B 67E6F8 DFFDB9 FFE800 B6F0F8)
134
- sheet.add_chart(::xls::Pie3DChart, :title => "post by author") do |chart|
135
- chart.add_series :data => data, :labels => labels, :colors => chart_color
136
- chart.start_at 4, 0
137
- chart.end_at 7, 20
122
+ column(:author) do |resource|
123
+ "#{resource.author.first_name} #{resource.author.last_name}"
124
+ end
125
+ after_filter do |sheet|
126
+ row_number = sheet.dimensions[1]
127
+ sheet.update_row(row_number)
128
+ row_number += 1
129
+ sheet.update_row(row_number, 'Author Name', 'Number of Posts')
130
+ users = collection.map(&:author).uniq(&:id)
131
+ users.each do |user|
132
+ row_number += 1
133
+ sheet.update_row(row_number,
134
+ "#{user.first_name} #{user.last_name}",
135
+ user.posts.size)
138
136
  end
139
- }
137
+ end
140
138
  before_filter do |sheet|
141
- collection.first.author.first_name = 'Set In Proc'
142
- sheet.add_row ['Created', Time.zone.now]
143
- sheet.add_row []
139
+ users = collection.map(&:author)
140
+ users.each do |user|
141
+ user.first_name = 'Set In Proc' if user.first_name == 'bob'
142
+ end
143
+ row_number = sheet.dimensions[1]
144
+ sheet.update_row(row_number, 'Created', Time.zone.now)
145
+ row_number += 1
146
+ sheet.update_row(row_number, '')
144
147
  end
145
148
  end
146
- }
149
+ end
147
150
 
148
- before(:all) do
149
- User.stub!(:all) { users }
150
- Post.stub!(:all) { posts }
151
- # disable clean up so we can get the package.
152
- builder.stub(:clean_up) { false }
151
+ before do
152
+ Post.all.each(&:destroy)
153
+ User.all.each(&:destroy)
154
+ @user = User.create!(first_name: 'bob', last_name: 'nancy')
155
+ @post = Post.create!(title: 'bob',
156
+ body: 'is a swell guy',
157
+ author: @user)
158
+ # disable clean up so we can get the book.
159
+ allow(builder).to receive(:clean_up) { false }
153
160
  builder.serialize(Post.all)
154
- @package = builder.send(:package)
161
+ @book = builder.send(:book)
155
162
  @collection = builder.collection
156
163
  end
157
164
 
158
165
  it 'provides the collection object' do
159
- @collection.count.should == Post.all.count
166
+ expect(@collection.count).to eq(Post.all.count)
160
167
  end
161
168
 
162
169
  it 'merges our customizations with the default header style' do
163
- builder.header_style[:sz].should be(10)
164
- builder.header_style[:fg_color].should == 'FF0000'
165
- builder.header_style[:bg_color].should == '00'
170
+ expect(builder.header_style[:size]).to eq(10)
171
+ expect(builder.header_style[:color]).to eq('red')
172
+ # expect(builder.header_style[:pattern_bg_color]).to eq('00')
166
173
  end
167
174
 
168
175
  it 'uses the specified i18n_scope' do
169
- builder.i18n_scope.should == [:xls, :post]
176
+ expect(builder.i18n_scope).to eq(%i[xls post])
170
177
  end
171
178
 
172
179
  it 'translates the header row based on our i18n scope' do
173
- header_row = @package.workbook.worksheets.first.rows[2]
174
- header_row.cells.map(&:value).should == ['Title', 'Content', 'Published On', 'Publisher']
180
+ header_row = @book.worksheets.first.row(2)
181
+ expect(header_row).to eq(['Title', 'Content', 'Published On', 'Publisher'])
175
182
  end
176
183
 
177
184
  it 'processes the before filter' do
178
- @package.workbook.worksheets.first["A1"].value.should == 'Created'
185
+ expect(@book.worksheets.first.cell(0, 0)).to eq('Created')
179
186
  end
180
187
 
181
188
  it 'lets us work against the collection in the before filter' do
182
- @package.workbook.worksheets.first.rows.last.cells.first.value.should == 'Set In Proc nancy'
183
- end
184
-
185
- it 'processes the after filter' do
186
- @package.workbook.charts.size.should == 1
187
- end
188
-
189
- it 'has no OOXML validation errors' do
190
- @package.validate.size.should == 0
189
+ expect(@book.worksheets.first.last_row[0]).to eq('Set In Proc nancy')
191
190
  end
192
191
  end
193
192
  end
@@ -3,48 +3,55 @@ require 'spec_helper'
3
3
  module ActiveAdmin
4
4
  module Xls
5
5
  describe ::ActiveAdmin::ResourceDSL do
6
- context 'in a registraiton block' do
7
- let(:builder) {
6
+ context 'in a registration block' do
7
+ let(:builder) do
8
8
  config = ActiveAdmin.register(Post) do
9
- xls(i18n_scope: [:rspec], header_style: { sz: 20 }) do
9
+ xls(i18n_scope: [:rspec], header_style: { size: 20 }) do
10
10
  delete_columns :id, :created_at
11
11
  column(:author) { |post| post.author.first_name }
12
- before_filter { |sheet| sheet.add_row ['before_filter'] }
13
- after_filter { |sheet| sheet.add_row['after_filter'] }
12
+ before_filter do |sheet|
13
+ row_number = sheet.dimensions[1]
14
+ sheet.update_row(row_number, 'before_filter')
15
+ end
16
+ after_filter do |sheet|
17
+ row_number = sheet.dimensions[1]
18
+ sheet.update_row(row_number, 'after_filter')
19
+ end
14
20
  skip_header
15
21
  end
16
22
  end
17
23
  config.xls_builder
18
- }
19
-
24
+ end
20
25
 
21
- it "uses our customized i18n scope" do
22
- builder.i18n_scope.should == [:rspec]
26
+ it 'uses our customized i18n scope' do
27
+ expect(builder.i18n_scope).to eq([:rspec])
23
28
  end
24
29
 
25
- it "removed the columns we told it to ignore" do
26
- [:id, :create_at].each do |removed|
27
- builder.columns.index{|column| column.name == removed}.should be_nil
30
+ it 'removed the columns we told it to ignore' do
31
+ %i[id create_at].each do |removed|
32
+ column_index = builder.columns.index { |col| col.name == removed }
33
+ expect(column_index).to be_nil
28
34
  end
29
35
  end
30
36
 
31
- it "added the columns we declared" do
32
- builder.columns.index{ |column| column.name == :author}.should_not be_nil
37
+ it 'added the columns we declared' do
38
+ added_index = builder.columns.index { |col| col.name == :author }
39
+ expect(added_index).not_to be_nil
33
40
  end
34
41
 
35
- it "has a before filter set" do
36
- builder.instance_values["before_filter"].should be_a(Proc)
42
+ it 'has a before filter set' do
43
+ expect(builder.instance_values['before_filter']).to be_a(Proc)
37
44
  end
38
- it "has an after filter set" do
39
- builder.instance_values["after_filter"].should be_a(Proc)
45
+ it 'has an after filter set' do
46
+ expect(builder.instance_values['after_filter']).to be_a(Proc)
40
47
  end
41
48
 
42
- it "indicates that the header should be excluded" do
43
- builder.instance_values['skip_header'].should be_true
49
+ it 'indicates that the header should be excluded' do
50
+ expect(builder.instance_values['skip_header']).to be_truthy
44
51
  end
45
52
 
46
- it "updates the header style" do
47
- builder.header_style[:sz].should be(20)
53
+ it 'updates the header style' do
54
+ expect(builder.header_style[:size]).to eq(20)
48
55
  end
49
56
  end
50
57
  end
@@ -1,6 +1,5 @@
1
1
  require 'spec_helper'
2
2
  describe ActiveAdmin::ResourceController do
3
-
4
3
  let(:mime) { Mime::Type.lookup_by_extension(:xls) }
5
4
 
6
5
  let(:request) do
@@ -18,27 +17,36 @@ describe ActiveAdmin::ResourceController do
18
17
  end
19
18
  end
20
19
 
21
- let(:filename) { "#{controller.resource_class.to_s.downcase.pluralize}-#{Time.now.strftime("%Y-%m-%d")}.xls" }
20
+ let(:filename) do
21
+ "#{controller.resource_class.to_s.downcase.pluralize}-#{Time.now.strftime('%Y-%m-%d')}.xls"
22
+ end
22
23
 
23
24
  it 'generates an xls filename' do
24
- controller.xls_filename.should == filename
25
+ expect(controller.xls_filename).to eq(filename)
25
26
  end
26
27
 
27
28
  context 'when making requests with the xls mime type' do
28
- it 'returns xls attachment when requested' do
29
+ it 'returns xls attachment when requested' do
29
30
  controller.send :index
30
- response.headers["Content-Disposition"].should == "attachment; filename=\"#{filename}\""
31
- response.headers["Content-Transfer-Encoding"].should == 'binary'
31
+ disposition = "attachment; filename=\"#{filename}\""
32
+ expect(response.headers['Content-Disposition']).to eq(disposition)
33
+ expect(response.headers['Content-Transfer-Encoding']).to eq('binary')
32
34
  end
33
35
 
34
36
  it 'returns max_csv_records for per_page' do
35
- controller.send(:per_page).should == controller.send(:max_csv_records)
37
+ # this might need to go away!
38
+ max_csv_records = if controller.respond_to?(:max_csv_records, true)
39
+ controller.send(:max_csv_records)
40
+ else
41
+ controller.send(:per_page)
42
+ end
43
+ expect(controller.send(:per_page)).to eq(max_csv_records)
36
44
  end
37
45
 
38
- it 'kicks back to the default per_page when we are not specifying a xls mime type' do
46
+ it 'uses to the default per_page when we do not specify xls mime type' do
39
47
  controller.request.accept = 'text/html'
40
- controller.send(:per_page).should == ActiveAdmin.application.default_per_page
48
+ aa_default_per_page = ActiveAdmin.application.default_per_page
49
+ expect(controller.send(:per_page)).to eq(aa_default_per_page)
41
50
  end
42
51
  end
43
52
  end
44
-
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require 'spec_helper'
2
2
  include ActiveAdmin
3
3
 
4
4
  module ActiveAdmin
@@ -7,18 +7,18 @@ module ActiveAdmin
7
7
  let(:resource) { ActiveAdmin.register(Post) }
8
8
 
9
9
  let(:custom_builder) do
10
- Builder.new(Post) do |builder|
10
+ Builder.new(Post) do
11
11
  column(:fake) { :fake }
12
12
  end
13
13
  end
14
14
 
15
15
  context 'when registered' do
16
- it "each resource has an xls_builer" do
17
- resource.xls_builder.should be_a(Builder)
16
+ it 'each resource has an xls_builder' do
17
+ expect(resource.xls_builder).to be_a(Builder)
18
18
  end
19
19
 
20
- it "We can specify our own configured builder" do
21
- lambda { resource.xls_builder = custom_builder }.should_not raise_error
20
+ it 'We can specify our own configured builder' do
21
+ expect { resource.xls_builder = custom_builder }.not_to raise_error
22
22
  end
23
23
  end
24
24
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activeadmin-xls
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Todd Hambley
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-22 00:00:00.000000000 Z
11
+ date: 2017-11-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activeadmin
@@ -51,8 +51,8 @@ executables: []
51
51
  extensions: []
52
52
  extra_rdoc_files: []
53
53
  files:
54
- - ".bundle/config"
55
54
  - ".editorconfig"
55
+ - ".gemignore"
56
56
  - ".gitignore"
57
57
  - ".rspec"
58
58
  - ".yardops"
@@ -62,6 +62,8 @@ files:
62
62
  - README.md
63
63
  - Rakefile
64
64
  - activeadmin-xls.gemspec
65
+ - gemfiles/rails_32.gemfile
66
+ - gemfiles/rails_42.gemfile
65
67
  - lib/active_admin/xls/builder.rb
66
68
  - lib/active_admin/xls/dsl.rb
67
69
  - lib/active_admin/xls/engine.rb
@@ -105,16 +107,4 @@ rubygems_version: 2.4.5.2
105
107
  signing_key:
106
108
  specification_version: 4
107
109
  summary: Adds excel (xls) downloads for resources within the Active Admin framework.
108
- test_files:
109
- - spec/spec_helper.rb
110
- - spec/support/rails_template.rb
111
- - spec/support/rails_template_with_data.rb
112
- - spec/support/templates/admin/stores.rb
113
- - spec/support/templates/cucumber.rb
114
- - spec/support/templates/cucumber_with_reloading.rb
115
- - spec/support/templates/en.yml
116
- - spec/xls/unit/builder_spec.rb
117
- - spec/xls/unit/build_download_format_links_spec.rb
118
- - spec/xls/unit/dsl_spec.rb
119
- - spec/xls/unit/resource_controller_spec.rb
120
- - spec/xls/unit/resource_spec.rb
110
+ test_files: []
@@ -1 +0,0 @@
1
- --- {}