houston-core 0.8.3 → 0.8.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8f11c47960bbc475231f9b6561811960bd8a58e3
4
- data.tar.gz: 39aafe18371c39efcd82cd03a405f56ce91b3548
3
+ metadata.gz: bb13d5eecf56a92b97bf57602f08952d35e5c939
4
+ data.tar.gz: 657f17128b2853f46c5dc1133bd2ee2afd61d42a
5
5
  SHA512:
6
- metadata.gz: b35f5368c098de2509a399b2e42e4d69090118e3af08defbce752ce0d3636a69f9ed07de850397b1a3fa27e538c83c4a12f355ab9cca1cc7bac05436a260dfac
7
- data.tar.gz: ca852de3146dbc304fec753f44e46b5a7f4237fb9d5d3c032cef4f590a9fcb9b81d9c1690e08b5c915a7162f27feb85a0e218a02853bd4489efa5fcd3286e1ab
6
+ metadata.gz: fcecec80ae7c7a153d232d4db2f01a7ee31b95dc4918091df07dd34755b62b6a4d45dab3bae64c5a02833b5606285f1dc6a71aee7a95268c3b9db1fbe46fd42b
7
+ data.tar.gz: 6e2e4e806e8eaef10afd1eeffa3df4a4a007c8091c3c046cb5b10721d00b4f8b8d261f6b2e322c958727fa442216ae5789bba26027ed21d03e563209fc9618e2
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- houston-core (0.8.3)
4
+ houston-core (0.8.4)
5
5
  activerecord-import
6
6
  activerecord-pluck_in_batches (~> 0.2.0)
7
7
  addressable (~> 2.3.8)
@@ -21,7 +21,7 @@ PATH
21
21
  houston-vestal_versions
22
22
  neat-rails
23
23
  nested_editor_for
24
- nokogiri
24
+ nokogiri (~> 1.7)
25
25
  oauth2
26
26
  oj (~> 2.18)
27
27
  openxml-xlsx (>= 0.2.0)
@@ -177,7 +177,7 @@ GEM
177
177
  nested_editor_for (0.1.1)
178
178
  net-ldap (0.12.1)
179
179
  nio4r (1.2.1)
180
- nokogiri (1.7.0.1)
180
+ nokogiri (1.7.1)
181
181
  mini_portile2 (~> 2.1.0)
182
182
  oauth2 (1.3.0)
183
183
  faraday (>= 0.8, < 0.11)
@@ -186,10 +186,10 @@ GEM
186
186
  multi_xml (~> 0.5)
187
187
  rack (>= 1.2, < 3)
188
188
  oj (2.18.1)
189
- openxml-package (0.2.6)
189
+ openxml-package (0.2.7)
190
190
  nokogiri
191
191
  ox
192
- rubyzip (~> 1.1.0)
192
+ rubyzip (~> 1.2.1)
193
193
  openxml-xlsx (0.2.3)
194
194
  nokogiri
195
195
  openxml-package (>= 0.2.0)
@@ -242,7 +242,7 @@ GEM
242
242
  railties (>= 4.2.0, < 5.1)
243
243
  rr (1.2.0)
244
244
  ruby-progressbar (1.8.1)
245
- rubyzip (1.1.7)
245
+ rubyzip (1.2.1)
246
246
  rufus-scheduler (3.2.2)
247
247
  safe_yaml (1.0.4)
248
248
  sass (3.4.23)
@@ -136,4 +136,27 @@ window.App =
136
136
  $form.find('.alert').remove()
137
137
  Errors.fromResponse(response).renderToAlert().prependTo $form
138
138
 
139
+ confirmDelete: (options)->
140
+ html = """
141
+ <div class="modal hide">
142
+ <form class="form-horizontal" action="#{options.url}" method="POST">
143
+ <input type="hidden" name="_method" value="delete">
144
+ <input type="hidden" name="#{App.meta('csrf-param')}" value="#{App.meta('csrf-token')}">
145
+ <div class="modal-header">
146
+ <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
147
+ <h3>Delete #{options.resource}</h3>
148
+ </div>
149
+ <div class="modal-body">
150
+ #{options.message}
151
+ </div>
152
+ <div class="modal-footer">
153
+ <button data-dismiss="modal" class="btn btn-default">Cancel</button>
154
+ <button type="submit" class="btn btn-danger">Delete #{options.resource}</button>
155
+ </div>
156
+ </form>
157
+ </div>
158
+ """
159
+ $modal = $(html).modal()
160
+ $modal.on 'hidden', -> $(@).remove()
161
+
139
162
  window.Houston = window.App
@@ -6,7 +6,7 @@ class ProjectsController < ApplicationController
6
6
 
7
7
  def index
8
8
  @title = "Projects"
9
- @projects = Project.unretired
9
+ @projects = Project.preload(:team).unretired
10
10
  end
11
11
 
12
12
 
@@ -5,7 +5,7 @@ module AvatarHelper
5
5
  def avatar_for(user, options={})
6
6
  size = options.fetch(:size, 24)
7
7
 
8
- return "<div class=\"avatar avatar-empty\" style=\"width:#{size}px; height:#{size}px\" />".html_safe unless user
8
+ return "<div class=\"avatar avatar-empty\" style=\"width:#{size}px; height:#{size}px\"></div>".html_safe unless user
9
9
 
10
10
  "<img class=\"avatar user-#{user.id}\" src=\"#{gravatar_url(user.email, size: size * 2)}\" width=\"#{size}\" height=\"#{size}\" alt=\"#{user.name}\" />".html_safe
11
11
  end
@@ -46,7 +46,7 @@ class Project < ActiveRecord::Base
46
46
 
47
47
 
48
48
 
49
- # Teammates
49
+ # Features
50
50
  # ------------------------------------------------------------------------- #
51
51
 
52
52
  def self.with_feature(feature)
data/houston-core.gemspec CHANGED
@@ -42,7 +42,7 @@ Gem::Specification.new do |spec|
42
42
  spec.add_dependency "gemoji", "~> 2.1.0"
43
43
  spec.add_dependency "handlebars_assets", "~> 0.23.0"
44
44
  spec.add_dependency "neat-rails"
45
- spec.add_dependency "nokogiri"
45
+ spec.add_dependency "nokogiri", "~> 1.7"
46
46
  spec.add_dependency "oauth2"
47
47
  spec.add_dependency "oj", "~> 2.18"
48
48
  spec.add_dependency "openxml-xlsx", ">= 0.2.0"
@@ -7,13 +7,9 @@ module Houston
7
7
 
8
8
  def pack(record)
9
9
  model = record.class
10
+ type_caster = model.type_caster
10
11
  normal_attributes = record.attributes.each_with_object({}) do |(attribute, value), attributes|
11
- column = model.column_for_attribute(attribute)
12
-
13
- # Don't serialize the attribute if the column was deleted
14
- next if column.is_a?(ActiveRecord::ConnectionAdapters::NullColumn)
15
-
16
- attributes[attribute] = model.connection.type_cast_from_column(column, value)
12
+ attributes[attribute] = type_caster.type_cast_for_database(attribute, value)
17
13
  end
18
14
  { "class" => model.name, "attributes" => normal_attributes }
19
15
  end
@@ -1,3 +1,3 @@
1
1
  module Houston
2
- VERSION = "0.8.3"
2
+ VERSION = "0.8.4"
3
3
  end
@@ -38,6 +38,20 @@ class SerializerTest < ActiveSupport::TestCase
38
38
  like: /"class":"Project","attributes":{.*},"\^S":"Houston::ActiveRecordSerializer"/)
39
39
  end
40
40
 
41
+ should "not explode when trying to serialize an object with an attribute that isn't a column" do
42
+ serialized_project = '{"class":"Project","attributes":{"id":18,"name":"Example","missing_column":true},"^S":"Houston::ActiveRecordSerializer"}'
43
+ project_with_bad_attribute = load(serialized_project)
44
+ refute_raises do
45
+ dump(project_with_bad_attribute)
46
+ end
47
+ end
48
+
49
+ should "serialize serialized attributes correctly" do
50
+ action = Action.new(params: {key: "value"})
51
+ assert_serializes(action,
52
+ like: /"params":"{\\\":key\\\":\\\"value\\\"}"/)
53
+ end
54
+
41
55
  should "work even when you set a value" do
42
56
  project = Project.create!(name: "Test", slug: "test")
43
57
  project.updated_at = 1.week.after(project.updated_at) # ActiveSupport::TimeWithZone
@@ -58,7 +72,11 @@ private
58
72
  assert_match expectation, serialized, "The object wasn't serialized as expected"
59
73
  end
60
74
 
61
- assert_equal object, load(serialized), "The object wasn't deserialized as expected"
75
+ if object.is_a?(ActiveRecord::Base)
76
+ assert_equal object.attributes, load(serialized)&.attributes, "The object wasn't deserialized as expected"
77
+ else
78
+ assert_equal object, load(serialized), "The object wasn't deserialized as expected"
79
+ end
62
80
  end
63
81
 
64
82
  def load(string)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: houston-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.3
4
+ version: 0.8.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bob Lail
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-18 00:00:00.000000000 Z
11
+ date: 2017-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -266,16 +266,16 @@ dependencies:
266
266
  name: nokogiri
267
267
  requirement: !ruby/object:Gem::Requirement
268
268
  requirements:
269
- - - ">="
269
+ - - "~>"
270
270
  - !ruby/object:Gem::Version
271
- version: '0'
271
+ version: '1.7'
272
272
  type: :runtime
273
273
  prerelease: false
274
274
  version_requirements: !ruby/object:Gem::Requirement
275
275
  requirements:
276
- - - ">="
276
+ - - "~>"
277
277
  - !ruby/object:Gem::Version
278
- version: '0'
278
+ version: '1.7'
279
279
  - !ruby/object:Gem::Dependency
280
280
  name: oauth2
281
281
  requirement: !ruby/object:Gem::Requirement