activeadmin 0.4.2 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of activeadmin might be problematic. Click here for more details.

@@ -1,5 +1,11 @@
1
1
  ## Master (unreleased)
2
2
 
3
+ ## 0.4.3
4
+
5
+ ### Bug Fixes
6
+
7
+ * [#1063][]: Fix comment issues when using postgres ([@jancel][])
8
+
3
9
  ## 0.4.2
4
10
 
5
11
  ### Enhancements
@@ -515,6 +521,7 @@ of the highlights. 250 commits. Enough said.
515
521
  [#1032]: https://github.com/gregbell/active_admin/issues/1032
516
522
  [#1033]: https://github.com/gregbell/active_admin/issues/1033
517
523
  [#1041]: https://github.com/gregbell/active_admin/issues/1041
524
+ [#1063]: https://github.com/gregbell/active_admin/issues/1063
518
525
  [@BoboFraggins]: https://github.com/BoboFraggins
519
526
  [@DMajrekar]: https://github.com/DMajrekar
520
527
  [@ZequeZ]: https://github.com/ZequeZ
@@ -19,13 +19,27 @@ module ActiveAdmin
19
19
  def self.resource_type(record)
20
20
  record.class.base_class.name.to_s
21
21
  end
22
+
23
+ def self.resource_id_cast(record)
24
+ # Postgres adapters won't compare strings to numbers (issue 34)
25
+ if resource_id_type == :string
26
+ record.id.to_s
27
+ else
28
+ record.id
29
+ end
30
+ end
22
31
 
23
32
  def self.find_for_resource_in_namespace(resource, namespace)
24
33
  where(:resource_type => resource_type(resource),
25
- :resource_id => resource.id,
34
+ :resource_id => resource_id_cast(resource),
26
35
  :namespace => namespace.to_s)
27
36
  end
28
37
 
38
+
39
+ def self.resource_id_type
40
+ columns.select { |i| i.name == "resource_id" }.first.type
41
+ end
42
+
29
43
  end
30
44
 
31
45
  end
@@ -1,3 +1,3 @@
1
1
  module ActiveAdmin
2
- VERSION = '0.4.2'
2
+ VERSION = '0.4.3'
3
3
  end
@@ -37,6 +37,24 @@ describe "Comments" do
37
37
  end
38
38
  end
39
39
 
40
+ describe ".resource_id_cast" do
41
+ let(:post) { Post.create!(:title => "Testing.") }
42
+ let(:namespace_name) { "admin" }
43
+
44
+ it "should cast resource_id as string" do
45
+ comment = ActiveAdmin::Comment.create! :resource => post,
46
+ :body => "Another Comment",
47
+ :namespace => namespace_name
48
+ ActiveAdmin::Comment.resource_id_cast(comment).class.should eql String
49
+ end
50
+ end
51
+
52
+ describe ".resource_id_type" do
53
+ it "should be :string" do
54
+ ActiveAdmin::Comment.resource_id_type.should eql :string
55
+ end
56
+ end
57
+
40
58
  describe "Commenting on resource with string id" do
41
59
  let(:tag){ Tag.create!(:name => "cooltags") }
42
60
  let(:namespace_name){ "admin" }
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activeadmin
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
4
+ hash: 9
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 2
10
- version: 0.4.2
9
+ - 3
10
+ version: 0.4.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Greg Bell
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-02-21 00:00:00 Z
18
+ date: 2012-03-08 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  version_requirements: &id001 !ruby/object:Gem::Requirement