graph_starter 0.15.5 → 0.15.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/helpers/graph_starter/application_helper.rb +1 -1
- data/app/models/graph_starter/asset.rb +24 -1
- data/app/views/graph_starter/assets/_admin_buttons.html.slim +12 -11
- data/app/views/graph_starter/assets/_associations.html.slim +2 -2
- data/app/views/graph_starter/assets/_body.html.slim +1 -1
- data/app/views/graph_starter/assets/show.html.slim +6 -6
- data/lib/graph_starter/version.rb +1 -1
- data/spec/asset_slug_spec.rb +35 -0
- data/spec/spec_helper.rb +28 -0
- metadata +17 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 846d2b3c24ae439f3e2431a4cfc1662fdf320f47
|
4
|
+
data.tar.gz: 7d0bb849a37a60e4c77f5318288ee82282fecc5e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f27817808730ca4c850a96bd5551d843b9fadb1be1d2c76de88dccce7e09da1701d6aa6c891e30aa631fd426a84418a3373bade7fe92481630ee73d31984de9
|
7
|
+
data.tar.gz: f58a50e1a8dd9b1749c76123d71c647db8c33d3f1fb6b69de20ed6f80dad8ebe875aa38b6729f1dc79e773b8b638075c0bcfc0a9286799114f87ddc5b3d66b1e
|
@@ -11,7 +11,7 @@ module GraphStarter
|
|
11
11
|
def render_body(asset, model_slug)
|
12
12
|
views = Dir.glob(Rails.root.join("app/views/#{model_slug}/_body.html.*"))
|
13
13
|
|
14
|
-
partial_path = views.present? ? "#{model_slug}/body" : 'body'
|
14
|
+
partial_path = views.present? ? "#{model_slug}/body" : '/graph_starter/assets/body'
|
15
15
|
|
16
16
|
render partial: partial_path, locals: {asset: asset}
|
17
17
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'graph_starter/query_authorizer'
|
2
|
+
require 'babosa'
|
2
3
|
|
3
4
|
module GraphStarter
|
4
5
|
class Asset
|
@@ -11,6 +12,28 @@ module GraphStarter
|
|
11
12
|
|
12
13
|
property :summary
|
13
14
|
|
15
|
+
|
16
|
+
# This is doing something strange, commenting out for now...
|
17
|
+
# def self.inherited(subclass)
|
18
|
+
# subclass.property :slug
|
19
|
+
# subclass.before_validation :place_slug
|
20
|
+
# subclass.validates :slug, presence: true
|
21
|
+
# subclass.constraint :slug, type: :unique
|
22
|
+
# end
|
23
|
+
|
24
|
+
def place_slug
|
25
|
+
return if self.slug.present?
|
26
|
+
|
27
|
+
name_value = read_attribute(self.class.name_property)
|
28
|
+
self.slug = self.class.unique_slug_from(name_value)
|
29
|
+
name_value.to_slug.normalize.to_s if name_value
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.unique_slug_from(string)
|
33
|
+
base = string.to_slug.normalize.to_s
|
34
|
+
end
|
35
|
+
|
36
|
+
|
14
37
|
if GraphStarter.configuration.user_class
|
15
38
|
#has_many :in, :creators, type: :CREATED, model_class: GraphStarter.configuration.user_class
|
16
39
|
|
@@ -95,7 +118,7 @@ module GraphStarter
|
|
95
118
|
def self.enumerable_property(property_name, values)
|
96
119
|
fail "values needs to be an Array, was #{values.inspect}" if !values.is_a?(Array)
|
97
120
|
|
98
|
-
validates
|
121
|
+
validates property_name.to_sym, inclusion: {in: values}
|
99
122
|
|
100
123
|
enumerable_property_values[self.name.to_sym] ||= {}
|
101
124
|
enumerable_property_values[self.name.to_sym][property_name.to_sym] ||= values
|
@@ -1,17 +1,18 @@
|
|
1
|
-
.
|
2
|
-
|
3
|
-
|
1
|
+
- if asset.persisted?
|
2
|
+
.ui.buttons
|
3
|
+
a.ui.labeled.icon.button.right.floated data-authorizable="#{asset.to_json}"
|
4
|
+
| Permissions
|
4
5
|
|
5
|
-
|
6
|
+
.or
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
8
|
+
a.ui.labeled.icon.button.right.floated href="#{graph_starter.edit_asset_path(id: asset)}"
|
9
|
+
i.edit.icon
|
10
|
+
| Edit
|
10
11
|
|
11
|
-
.ui.divider
|
12
|
+
.ui.divider
|
12
13
|
|
13
|
-
a.ui.labeled.icon.red.button.right.floated href="#{destroy_asset_path(id: asset)}"
|
14
|
-
|
15
|
-
|
14
|
+
a.ui.labeled.icon.red.button.right.floated href="#{graph_starter.destroy_asset_path(id: asset)}"
|
15
|
+
i.delete.icon
|
16
|
+
| Delete
|
16
17
|
|
17
18
|
|
@@ -10,12 +10,12 @@
|
|
10
10
|
- if as_cards
|
11
11
|
.ui.link.cards
|
12
12
|
- Array(result).each do |object|
|
13
|
-
= render partial: 'card', locals: {asset: object}
|
13
|
+
= render partial: '/graph_starter/assets/card', locals: {asset: object}
|
14
14
|
- else
|
15
15
|
.ui.middle.aligned.big.divided.list
|
16
16
|
- Array(result).each do |object|
|
17
17
|
.item
|
18
18
|
.content
|
19
|
-
= render partial: 'icon', locals: {asset: object}
|
19
|
+
= render partial: '/graph_starter/assets/icon', locals: {asset: object}
|
20
20
|
= link_to object.title, asset_path(object)
|
21
21
|
|
@@ -14,24 +14,24 @@ javascript:
|
|
14
14
|
.ui.grid
|
15
15
|
- if asset_presenter.left_sidebar_exists?
|
16
16
|
div class="#{left_width} wide column"
|
17
|
-
= render partial: 'dynamic_items', locals: {asset: @asset}
|
17
|
+
= render partial: '/graph_starter/assets/dynamic_items', locals: {asset: @asset}
|
18
18
|
|
19
19
|
- if asset_presenter.main_column_exists?
|
20
20
|
div class="#{center_width} wide column"
|
21
21
|
- if asset_presenter.associations_in_body?
|
22
|
-
= render partial: 'associations', locals: {asset: @asset, as_cards: true}
|
22
|
+
= render partial: '/graph_starter/assets/associations', locals: {asset: @asset, as_cards: true}
|
23
23
|
- else
|
24
24
|
= render_body(@asset, @model_slug)
|
25
25
|
|
26
26
|
div class="#{right_width} wide column" id="right-column"
|
27
27
|
- if app_user_is_admin?
|
28
|
-
= render partial: 'admin_buttons', locals: {asset: @asset}
|
28
|
+
= render partial: '/graph_starter/assets/admin_buttons', locals: {asset: @asset}
|
29
29
|
|
30
30
|
- if !asset_presenter.left_sidebar_exists?
|
31
31
|
.ui.items
|
32
32
|
- if !asset_presenter.associations_in_body?
|
33
|
-
= render partial: 'associations', locals: {asset: @asset}
|
34
|
-
= render partial: 'recommendations', locals: {asset: @asset}
|
33
|
+
= render partial: '/graph_starter/assets/associations', locals: {asset: @asset}
|
34
|
+
= render partial: '/graph_starter/assets/recommendations', locals: {asset: @asset}
|
35
35
|
|
36
|
-
= render partial: 'property_items', locals: {asset: @asset}
|
36
|
+
= render partial: '/graph_starter/assets/property_items', locals: {asset: @asset}
|
37
37
|
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# require './spec/rails_helper'
|
2
|
+
#
|
3
|
+
# describe 'Asset slugs' do
|
4
|
+
# class Foo < GraphStarter::Asset
|
5
|
+
# property :title
|
6
|
+
#
|
7
|
+
# name_property :title
|
8
|
+
# end
|
9
|
+
#
|
10
|
+
# before { clear_db }
|
11
|
+
#
|
12
|
+
# describe '.unique_slug_from' do
|
13
|
+
# subject { GraphStarter::Asset.unique_slug_from(string) }
|
14
|
+
#
|
15
|
+
# context 'Without assets with slugs' do
|
16
|
+
# let_context string: 'Test title' do
|
17
|
+
# it { should eq 'test-title' }
|
18
|
+
# end
|
19
|
+
#
|
20
|
+
# let_context string: 'Gölcük, Turkey Number 2!' do
|
21
|
+
# it { should eq 'golcuk-turkey-number-2' }
|
22
|
+
# end
|
23
|
+
# end
|
24
|
+
#
|
25
|
+
# context 'With existing asset slugs' do
|
26
|
+
# before { Foo.create(title: 'Gölcük, Turkey', slug: 'golcuk-turkey') }
|
27
|
+
#
|
28
|
+
# let_context string: 'Gölcük, Turkey!' do
|
29
|
+
# it { should eq 'golcuk-turkey-2' }
|
30
|
+
# end
|
31
|
+
# end
|
32
|
+
#
|
33
|
+
# end
|
34
|
+
# end
|
35
|
+
|
data/spec/spec_helper.rb
CHANGED
@@ -1,3 +1,29 @@
|
|
1
|
+
|
2
|
+
# Introduces `let_context` helper method
|
3
|
+
# This allows us to simplify the case where we want to
|
4
|
+
# have a context which contains one or more `let` statements
|
5
|
+
module LetContextHelpers
|
6
|
+
# Supports giving either a Hash or a String and a Hash as arguments
|
7
|
+
# In both cases the Hash will be used to define `let` statements
|
8
|
+
# When a String is specified that becomes the context description
|
9
|
+
# If String isn't specified, Hash#inspect becomes the context description
|
10
|
+
def let_context(*args, &block)
|
11
|
+
classes = args.map(&:class)
|
12
|
+
context_string, hash =
|
13
|
+
case classes
|
14
|
+
when [String, Hash] then ["#{args[0]} #{args[1]}", args[1]]
|
15
|
+
when [Hash] then args + args
|
16
|
+
end
|
17
|
+
|
18
|
+
context(context_string) do
|
19
|
+
hash.each { |var, value| let(var) { value } }
|
20
|
+
|
21
|
+
instance_eval(&block)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
|
1
27
|
# This file was generated by the `rails generate rspec:install` command. Conventionally, all
|
2
28
|
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
29
|
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
@@ -40,6 +66,8 @@ RSpec.configure do |config|
|
|
40
66
|
mocks.verify_partial_doubles = true
|
41
67
|
end
|
42
68
|
|
69
|
+
config.extend LetContextHelpers
|
70
|
+
|
43
71
|
# The settings below are suggested to provide a good initial experience
|
44
72
|
# with RSpec, but feel free to customize to your heart's content.
|
45
73
|
=begin
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graph_starter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.15.
|
4
|
+
version: 0.15.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Underwood
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - '='
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: 0.0.3
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: babosa
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 1.0.2
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 1.0.2
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: rspec-rails
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -223,6 +237,7 @@ files:
|
|
223
237
|
- lib/graph_starter/version.rb
|
224
238
|
- lib/tasks/graph_starter_tasks.rake
|
225
239
|
- spec/asset_authorization_spec.rb
|
240
|
+
- spec/asset_slug_spec.rb
|
226
241
|
- spec/dummy/README.rdoc
|
227
242
|
- spec/dummy/Rakefile
|
228
243
|
- spec/dummy/app/assets/javascripts/application.js
|
@@ -289,6 +304,7 @@ specification_version: 4
|
|
289
304
|
summary: A Rails engine to get a UI for a Neo4j up and running quickly
|
290
305
|
test_files:
|
291
306
|
- spec/asset_authorization_spec.rb
|
307
|
+
- spec/asset_slug_spec.rb
|
292
308
|
- spec/dummy/app/assets/javascripts/application.js
|
293
309
|
- spec/dummy/app/assets/stylesheets/application.css
|
294
310
|
- spec/dummy/app/controllers/application_controller.rb
|