Skip to content

Commit e254fb6

Browse files
committed
[RAILS] Fixed the 01 and 02 templates on Rails 3.2.x
Related: elastic#73
1 parent cc90739 commit e254fb6

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

elasticsearch-rails/lib/rails/templates/01-basic.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@
184184
class Article < ActiveRecord::Base
185185
include Elasticsearch::Model
186186
include Elasticsearch::Model::Callbacks
187+
#{'attr_accessible :title, :content, :published_on' if Rails::VERSION::STRING < '4'}
187188
end
188189
CODE
189190

@@ -236,7 +237,7 @@ def search
236237
end
237238
CODE
238239

239-
gsub_file 'test/controllers/articles_controller_test.rb', %r{setup do.*?end}m, <<-CODE
240+
gsub_file "#{Rails::VERSION::STRING > '4' ? 'test/controllers' : 'test/functional'}/articles_controller_test.rb", %r{setup do.*?end}m, <<-CODE
240241
setup do
241242
@article = articles(:one)
242243
@@ -245,7 +246,7 @@ def search
245246
end
246247
CODE
247248

248-
inject_into_file 'test/controllers/articles_controller_test.rb', after: %r{test "should get index" do.*?end}m do
249+
inject_into_file "#{Rails::VERSION::STRING > '4' ? 'test/controllers' : 'test/functional'}/articles_controller_test.rb", after: %r{test "should get index" do.*?end}m do
249250
<<-CODE
250251
251252

elasticsearch-rails/lib/rails/templates/02-pretty.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def self.search(query)
8686
end
8787
CODE
8888

89-
gsub_file "test/models/article_test.rb", %r{# test "the truth" do.*?# end}m, <<-CODE
89+
gsub_file "#{Rails::VERSION::STRING > '4' ? 'test/models' : 'test/unit' }/article_test.rb", %r{# test "the truth" do.*?# end}m, <<-CODE
9090
9191
test "has a search method delegating to __elasticsearch__" do
9292
Article.__elasticsearch__.expects(:search).with do |definition|
@@ -98,7 +98,7 @@ def self.search(query)
9898
CODE
9999

100100
git add: "app/models/article.rb"
101-
git add: "test/models/article_test.rb"
101+
git add: "test/**/article_test.rb"
102102
git commit: "-m 'Added an `Article.search` method'"
103103

104104
# ----- Add loading Bootstrap assets --------------------------------------------------------------

0 commit comments

Comments
 (0)