compony 0.11.12 → 0.11.14
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.
- checksums.yaml +4 -4
- data/.rspec +2 -0
- data/CHANGELOG.md +16 -0
- data/CLAUDE.md +1 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +145 -106
- data/README.md +12 -1
- data/Rakefile +10 -0
- data/TODO.md +2 -1
- data/VERSION +1 -1
- data/compony.gemspec +5 -3
- data/doc/ComponentGenerator.html +1 -1
- data/doc/Components.html +1 -1
- data/doc/ComponentsGenerator.html +1 -1
- data/doc/Compony/Component.html +1 -1
- data/doc/Compony/ComponentMixins/Default/Labelling.html +1 -1
- data/doc/Compony/ComponentMixins/Default/Standalone/ResourcefulVerbDsl.html +1 -1
- data/doc/Compony/ComponentMixins/Default/Standalone/StandaloneDsl.html +1 -1
- data/doc/Compony/ComponentMixins/Default/Standalone/VerbDsl.html +1 -1
- data/doc/Compony/ComponentMixins/Default/Standalone.html +1 -1
- data/doc/Compony/ComponentMixins/Default.html +1 -1
- data/doc/Compony/ComponentMixins/Resourceful.html +1 -1
- data/doc/Compony/ComponentMixins.html +1 -1
- data/doc/Compony/Components/Buttons/CssButton.html +1 -1
- data/doc/Compony/Components/Buttons/Link.html +1 -1
- data/doc/Compony/Components/Buttons.html +1 -1
- data/doc/Compony/Components/Destroy.html +1 -1
- data/doc/Compony/Components/Edit.html +1 -1
- data/doc/Compony/Components/Form.html +41 -41
- data/doc/Compony/Components/Index.html +1 -1
- data/doc/Compony/Components/List.html +1 -1
- data/doc/Compony/Components/New.html +1 -1
- data/doc/Compony/Components/Show.html +1 -1
- data/doc/Compony/Components/WithForm.html +1 -1
- data/doc/Compony/Components.html +1 -1
- data/doc/Compony/ControllerMixin.html +1 -1
- data/doc/Compony/Engine.html +1 -1
- data/doc/Compony/Intent.html +1 -1
- data/doc/Compony/ManageIntentsDsl.html +2 -2
- data/doc/Compony/MethodAccessibleHash.html +1 -1
- data/doc/Compony/ModelFields/Anchormodel.html +1 -1
- data/doc/Compony/ModelFields/Association.html +1 -1
- data/doc/Compony/ModelFields/Attachment.html +1 -1
- data/doc/Compony/ModelFields/Base.html +8 -2
- data/doc/Compony/ModelFields/Boolean.html +1 -1
- data/doc/Compony/ModelFields/Color.html +1 -1
- data/doc/Compony/ModelFields/Currency.html +1 -1
- data/doc/Compony/ModelFields/Date.html +1 -1
- data/doc/Compony/ModelFields/Datetime.html +1 -1
- data/doc/Compony/ModelFields/Decimal.html +1 -1
- data/doc/Compony/ModelFields/Email.html +1 -1
- data/doc/Compony/ModelFields/Float.html +1 -1
- data/doc/Compony/ModelFields/Integer.html +1 -1
- data/doc/Compony/ModelFields/Percentage.html +1 -1
- data/doc/Compony/ModelFields/Phone.html +1 -1
- data/doc/Compony/ModelFields/RichText.html +1 -1
- data/doc/Compony/ModelFields/String.html +1 -1
- data/doc/Compony/ModelFields/Text.html +1 -1
- data/doc/Compony/ModelFields/Time.html +1 -1
- data/doc/Compony/ModelFields/Url.html +1 -1
- data/doc/Compony/ModelFields.html +1 -1
- data/doc/Compony/ModelMixin.html +13 -13
- data/doc/Compony/NaturalOrdering.html +1 -1
- data/doc/Compony/RequestContext.html +1 -1
- data/doc/Compony/Version.html +1 -1
- data/doc/Compony/ViewHelpers.html +1 -1
- data/doc/Compony/VirtualModel.html +1 -1
- data/doc/Compony.html +276 -92
- data/doc/ComponyController.html +1 -1
- data/doc/_index.html +1 -1
- data/doc/file.CHANGELOG.html +89 -77
- data/doc/file.README.html +21 -11
- data/doc/file.basic_component.html +14 -14
- data/doc/file.cookbook.html +27 -27
- data/doc/file.destroy.html +2 -2
- data/doc/file.dsl_reference.html +199 -199
- data/doc/file.edit.html +3 -3
- data/doc/file.example.html +13 -13
- data/doc/file.example_advanced.html +10 -10
- data/doc/file.feasibility.html +2 -2
- data/doc/file.form.html +20 -8
- data/doc/file.generators.html +3 -3
- data/doc/file.glossary.html +44 -44
- data/doc/file.gotchas.html +35 -35
- data/doc/file.index.html +10 -10
- data/doc/file.inheritance.html +5 -5
- data/doc/file.installation.html +9 -9
- data/doc/file.integrations.html +46 -46
- data/doc/file.intents.html +11 -11
- data/doc/file.internal_datastructures.html +6 -6
- data/doc/file.list.html +35 -35
- data/doc/file.maintaining.html +21 -21
- data/doc/file.model_fields.html +3 -3
- data/doc/file.nesting.html +5 -5
- data/doc/file.new.html +3 -3
- data/doc/file.ownership.html +2 -2
- data/doc/file.patterns.html +50 -50
- data/doc/file.pre_built_components.html +2 -2
- data/doc/file.resourceful.html +5 -5
- data/doc/file.show.html +17 -17
- data/doc/file.standalone.html +12 -12
- data/doc/file.virtual_models.html +2 -2
- data/doc/file.with_form.html +23 -23
- data/doc/guide/pre_built_components/form.md +21 -2
- data/doc/index.html +21 -11
- data/doc/method_list.html +16 -0
- data/doc/top-level-namespace.html +1 -1
- data/lib/compony/components/form.rb +5 -4
- data/lib/compony/model_fields/base.rb +3 -0
- data/lib/compony/model_mixin.rb +3 -2
- data/lib/compony.rb +19 -0
- data/spec/README.md +22 -0
- data/spec/compony/component_spec.rb +80 -0
- data/spec/compony/components/form_spec.rb +31 -0
- data/spec/compony/compony_spec.rb +130 -0
- data/spec/compony/intent_spec.rb +94 -0
- data/spec/compony/method_accessible_hash_spec.rb +32 -0
- data/spec/compony/model_fields_spec.rb +70 -0
- data/spec/compony/model_mixin_spec.rb +109 -0
- data/spec/compony/natural_ordering_spec.rb +61 -0
- data/spec/dummy/app/components/statics/home.rb +17 -0
- data/spec/dummy/app/components/statics/secret.rb +15 -0
- data/spec/dummy/app/components/users/destroy.rb +2 -0
- data/spec/dummy/app/components/users/edit.rb +2 -0
- data/spec/dummy/app/components/users/form.rb +14 -0
- data/spec/dummy/app/components/users/index.rb +29 -0
- data/spec/dummy/app/components/users/new.rb +2 -0
- data/spec/dummy/app/components/users/show.rb +26 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/models/ability.rb +7 -0
- data/spec/dummy/app/models/application_record.rb +4 -0
- data/spec/dummy/app/models/user.rb +22 -0
- data/spec/dummy/app/views/layouts/application.html.erb +7 -0
- data/spec/dummy/config/application.rb +20 -0
- data/spec/dummy/config/database.yml +3 -0
- data/spec/dummy/config/environment.rb +3 -0
- data/spec/dummy/config/initializers/simple_form.rb +9 -0
- data/spec/dummy/config/routes.rb +3 -0
- data/spec/dummy/db/schema.rb +14 -0
- data/spec/rails_helper.rb +23 -0
- data/spec/requests/authorization_spec.rb +16 -0
- data/spec/requests/plain_component_spec.rb +9 -0
- data/spec/requests/routing_spec.rb +20 -0
- data/spec/requests/users_crud_spec.rb +99 -0
- metadata +63 -1
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
RSpec.describe 'Users CRUD via pre-built components', type: :request do
|
|
2
|
+
describe 'index' do
|
|
3
|
+
it 'lists users with buttons' do
|
|
4
|
+
alice = User.create!(name: 'Alice')
|
|
5
|
+
get '/users'
|
|
6
|
+
expect(response).to have_http_status(:ok)
|
|
7
|
+
expect(response.body).to include('Alice')
|
|
8
|
+
expect(response.body).to include("/users/show/#{alice.id}")
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it 'disables the destroy button for admins (feasibility)' do
|
|
12
|
+
User.create!(name: 'Root', admin: true)
|
|
13
|
+
get '/users'
|
|
14
|
+
expect(response.body).to include('Cannot destroy admins.')
|
|
15
|
+
expect(response.body).to include('disabled')
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
describe 'show' do
|
|
20
|
+
it 'renders the fields of the user' do
|
|
21
|
+
user = User.create!(name: 'Alice', age: 30, comment: 'Hi there')
|
|
22
|
+
get "/users/show/#{user.id}"
|
|
23
|
+
expect(response).to have_http_status(:ok)
|
|
24
|
+
expect(response.body).to include('<h3>Alice</h3>')
|
|
25
|
+
expect(response.body).to include('Hi there')
|
|
26
|
+
expect(response.body).to include('30')
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it 'raises RecordNotFound for a missing id' do
|
|
30
|
+
expect { get '/users/show/999999' }.to raise_error(ActiveRecord::RecordNotFound)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
describe 'new/create' do
|
|
35
|
+
it 'renders the form' do
|
|
36
|
+
get '/users/new'
|
|
37
|
+
expect(response).to have_http_status(:ok)
|
|
38
|
+
expect(response.body).to include('form')
|
|
39
|
+
expect(response.body).to include('user[name]')
|
|
40
|
+
expect(response.body).to include('user[age]')
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
it 'creates a user and redirects' do
|
|
44
|
+
expect do
|
|
45
|
+
post '/users/new', params: { user: { name: 'Bob', age: '25', comment: 'New guy', email: 'bob@example.com', admin: '0', born_on: '2000-01-01' } }
|
|
46
|
+
end.to change(User, :count).by(1)
|
|
47
|
+
user = User.order(:id).last
|
|
48
|
+
expect(user.name).to eq('Bob')
|
|
49
|
+
expect(user.age).to eq(25)
|
|
50
|
+
expect(user.born_on).to eq(Date.new(2000, 1, 1))
|
|
51
|
+
expect(response).to have_http_status(:found)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it 're-renders the form on validation errors' do
|
|
55
|
+
expect do
|
|
56
|
+
post '/users/new', params: { user: { name: '' } }
|
|
57
|
+
end.not_to change(User, :count)
|
|
58
|
+
expect(response.body).to include('form')
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
describe 'edit/update' do
|
|
63
|
+
let(:user) { User.create!(name: 'Alice', age: 30) }
|
|
64
|
+
|
|
65
|
+
it 'renders the form with existing values' do
|
|
66
|
+
get "/users/#{user.id}/edit"
|
|
67
|
+
expect(response).to have_http_status(:ok)
|
|
68
|
+
expect(response.body).to include('Alice')
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
it 'updates the user and redirects' do
|
|
72
|
+
patch "/users/#{user.id}/edit", params: { user: { name: 'Alicia' } }
|
|
73
|
+
expect(user.reload.name).to eq('Alicia')
|
|
74
|
+
expect(response).to have_http_status(:found)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
it 'does not update on validation errors' do
|
|
78
|
+
patch "/users/#{user.id}/edit", params: { user: { name: '' } }
|
|
79
|
+
expect(user.reload.name).to eq('Alice')
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
describe 'destroy' do
|
|
84
|
+
it 'asks for confirmation on GET' do
|
|
85
|
+
user = User.create!(name: 'Alice')
|
|
86
|
+
get "/users/#{user.id}/destroy"
|
|
87
|
+
expect(response).to have_http_status(:ok)
|
|
88
|
+
expect(User.exists?(user.id)).to be(true)
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
it 'destroys on DELETE and redirects' do
|
|
92
|
+
user = User.create!(name: 'Alice')
|
|
93
|
+
expect do
|
|
94
|
+
delete "/users/#{user.id}/destroy"
|
|
95
|
+
end.to change(User, :count).by(-1)
|
|
96
|
+
expect(response).to have_http_status(:see_other) # 303 forces a GET, required for Turbo
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: compony
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.11.
|
|
4
|
+
version: 0.11.14
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sandro Kalbermatter
|
|
@@ -52,6 +52,34 @@ dependencies:
|
|
|
52
52
|
- - ">="
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
54
|
version: 2.18.0
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: rspec-rails
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '6.1'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '6.1'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: sqlite3
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '1.7'
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - ">="
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '1.7'
|
|
55
83
|
- !ruby/object:Gem::Dependency
|
|
56
84
|
name: rails
|
|
57
85
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -169,6 +197,7 @@ extensions: []
|
|
|
169
197
|
extra_rdoc_files: []
|
|
170
198
|
files:
|
|
171
199
|
- ".gitignore"
|
|
200
|
+
- ".rspec"
|
|
172
201
|
- ".ruby-version"
|
|
173
202
|
- ".yardopts"
|
|
174
203
|
- CHANGELOG.md
|
|
@@ -396,6 +425,39 @@ files:
|
|
|
396
425
|
- lib/generators/components/USAGE
|
|
397
426
|
- lib/generators/components/components_generator.rb
|
|
398
427
|
- logo.svg
|
|
428
|
+
- spec/README.md
|
|
429
|
+
- spec/compony/component_spec.rb
|
|
430
|
+
- spec/compony/components/form_spec.rb
|
|
431
|
+
- spec/compony/compony_spec.rb
|
|
432
|
+
- spec/compony/intent_spec.rb
|
|
433
|
+
- spec/compony/method_accessible_hash_spec.rb
|
|
434
|
+
- spec/compony/model_fields_spec.rb
|
|
435
|
+
- spec/compony/model_mixin_spec.rb
|
|
436
|
+
- spec/compony/natural_ordering_spec.rb
|
|
437
|
+
- spec/dummy/app/components/statics/home.rb
|
|
438
|
+
- spec/dummy/app/components/statics/secret.rb
|
|
439
|
+
- spec/dummy/app/components/users/destroy.rb
|
|
440
|
+
- spec/dummy/app/components/users/edit.rb
|
|
441
|
+
- spec/dummy/app/components/users/form.rb
|
|
442
|
+
- spec/dummy/app/components/users/index.rb
|
|
443
|
+
- spec/dummy/app/components/users/new.rb
|
|
444
|
+
- spec/dummy/app/components/users/show.rb
|
|
445
|
+
- spec/dummy/app/controllers/application_controller.rb
|
|
446
|
+
- spec/dummy/app/models/ability.rb
|
|
447
|
+
- spec/dummy/app/models/application_record.rb
|
|
448
|
+
- spec/dummy/app/models/user.rb
|
|
449
|
+
- spec/dummy/app/views/layouts/application.html.erb
|
|
450
|
+
- spec/dummy/config/application.rb
|
|
451
|
+
- spec/dummy/config/database.yml
|
|
452
|
+
- spec/dummy/config/environment.rb
|
|
453
|
+
- spec/dummy/config/initializers/simple_form.rb
|
|
454
|
+
- spec/dummy/config/routes.rb
|
|
455
|
+
- spec/dummy/db/schema.rb
|
|
456
|
+
- spec/rails_helper.rb
|
|
457
|
+
- spec/requests/authorization_spec.rb
|
|
458
|
+
- spec/requests/plain_component_spec.rb
|
|
459
|
+
- spec/requests/routing_spec.rb
|
|
460
|
+
- spec/requests/users_crud_spec.rb
|
|
399
461
|
licenses: []
|
|
400
462
|
metadata: {}
|
|
401
463
|
rdoc_options: []
|