cookbook 0.1.2 → 0.1.6

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.
@@ -42,17 +42,6 @@ RSpec.describe Cookbook::Use, type: :model do
42
42
  it { should belong_to(:use_in) }
43
43
  end
44
44
 
45
- describe 'Scopes' do
46
- describe '.recipe_uses' do
47
- subject { Cookbook::Use.recipe_uses }
48
- it { should include(full_use) }
49
- end
50
- describe '.ingredient_uses' do
51
- subject { Cookbook::Use.ingredient_uses }
52
- it { should include(full_use) }
53
- end
54
- end
55
-
56
45
  describe 'Methods' do
57
46
  describe '#quantity' do
58
47
  describe 'when min and max exist' do
@@ -61,11 +50,11 @@ RSpec.describe Cookbook::Use, type: :model do
61
50
  end
62
51
  describe 'with just min' do
63
52
  subject { use_no_max_no_unit.quantity }
64
- it { should eq '0.25' } # ndash, not hyphen
53
+ it { should eq '0.25' }
65
54
  end
66
55
  describe 'with just max' do
67
56
  subject { use_no_min_no_unit.quantity }
68
- it { should eq '2' } # ndash, not hyphen
57
+ it { should eq '2' }
69
58
  end
70
59
  end
71
60
  describe '#quantity and unit' do
@@ -7,12 +7,12 @@ RSpec.describe HowTo, type: :model do
7
7
  it { should have_many(:uses) }
8
8
 
9
9
  it { should_not have_many(:ingredient_uses) }
10
- it { should_not have_many(:ingredients).through(:uses) }
10
+ it { should_not have_many(:ingredients).through(:ingredient_uses) }
11
11
 
12
12
  it { should have_many(:supply_uses) }
13
- it { should have_many(:supplies).through(:uses) }
13
+ it { should have_many(:supplies).through(:supply_uses) }
14
14
 
15
15
  it { should have_many(:tool_uses) }
16
- it { should have_many(:tools).through(:uses) }
16
+ it { should have_many(:tools).through(:tool_uses) }
17
17
  end
18
18
  end
@@ -7,12 +7,12 @@ RSpec.describe Recipe, type: :model do
7
7
  it { should have_many(:uses) }
8
8
 
9
9
  it { should have_many(:ingredient_uses) }
10
- it { should have_many(:ingredients).through(:uses) }
10
+ it { should have_many(:ingredients).through(:ingredient_uses) }
11
11
 
12
12
  it { should have_many(:supply_uses) }
13
- it { should have_many(:supplies).through(:uses) }
13
+ it { should have_many(:supplies).through(:supply_uses) }
14
14
 
15
15
  it { should have_many(:tool_uses) }
16
- it { should have_many(:tools).through(:uses) }
16
+ it { should have_many(:tools).through(:tool_uses) }
17
17
  end
18
18
  end
@@ -69,13 +69,13 @@ module Cookbook
69
69
  let(:new_attributes) do
70
70
  {
71
71
  name: 'Foo',
72
- tool_uses_attributes: [
73
- {
72
+ tool_uses_attributes: {
73
+ 0 => {
74
74
  use_of_id: tool.id,
75
75
  use_of_type: 'Tool',
76
76
  note: 'Test Note'
77
77
  }
78
- ]
78
+ }
79
79
  }
80
80
  end
81
81
  context 'with valid parameters' do
@@ -71,13 +71,13 @@ module Cookbook
71
71
  let(:new_attributes) do
72
72
  {
73
73
  name: 'Foo',
74
- ingredient_uses_attributes: [
75
- {
74
+ ingredient_uses_attributes: {
75
+ 0 => {
76
76
  use_of_id: ingredient.id,
77
77
  use_of_type: 'Ingredient',
78
78
  note: 'Test Note'
79
79
  }
80
- ]
80
+ }
81
81
  }
82
82
  end
83
83
  context 'with valid parameters' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cookbook
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Loren Lundgren
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-13 00:00:00.000000000 Z
11
+ date: 2021-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -56,7 +56,7 @@ dependencies:
56
56
  requirements:
57
57
  - - ">="
58
58
  - !ruby/object:Gem::Version
59
- version: '6'
59
+ version: '5'
60
60
  - - "<"
61
61
  - !ruby/object:Gem::Version
62
62
  version: '7'
@@ -66,7 +66,7 @@ dependencies:
66
66
  requirements:
67
67
  - - ">="
68
68
  - !ruby/object:Gem::Version
69
- version: '6'
69
+ version: '5'
70
70
  - - "<"
71
71
  - !ruby/object:Gem::Version
72
72
  version: '7'
@@ -339,14 +339,17 @@ files:
339
339
  - README.md
340
340
  - Rakefile
341
341
  - VERSION
342
+ - app/assets/javascript/cookbook/addFields.js
343
+ - app/assets/javascript/cookbook/application.js
344
+ - app/assets/javascript/cookbook/removeFields.js
342
345
  - app/assets/stylesheets/cookbook/application.scss
343
346
  - app/controllers/concerns/cookbook/params.rb
344
347
  - app/helpers/cookbook/application_helper.rb
345
348
  - app/models/cookbook/use.rb
346
349
  - app/views/cookbook/_fields.html.haml
350
+ - app/views/cookbook/_use_fields.html.haml
347
351
  - app/views/cookbook/_used_in.html.haml
348
352
  - app/views/cookbook/_uses_of.html.haml
349
- - app/views/cookbook/uses/_fields.html.haml
350
353
  - bin/rails
351
354
  - config/initializers/simple_form.rb
352
355
  - config/locales/simple_form.en.yml
@@ -1,17 +0,0 @@
1
- :ruby
2
- table_sym = form.object_name.gsub(/[^\[]+\[([^\]]+)_uses_attributes\].*/, "\\1").pluralize
3
- model = table_sym.to_s.classify.constantize
4
- collection = if Cookbook.configuration.authorize_with == :cancancan
5
- model.accessible_by(current_ability, :select)
6
- else
7
- model.all
8
- end
9
- = form.hidden_field :use_of_type, value: model.model_name.to_s
10
- = form.input :use_of_id, collection: collection, as: :select, label_method: model.label_method, value_method: :id, selected: form.object.use_of_id, include_blank: "Select #{model.model_name.human}"
11
- = form.input :quantity_minimum
12
- = form.input :quantity_maximum
13
- = form.input :unit
14
- = form.input :sort
15
- = form.input :preparation, hint: 'like "crushed" or "greased"'
16
- = form.input :note, hint: 'like "to taste"'
17
- = link_to_remove_nested(form, link_classes: 'button button-danger')