dry_crud 5.2.0 → 6.0.0
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/README.rdoc +50 -50
- data/VERSION +1 -1
- data/app/helpers/dry_crud/form/builder.rb +16 -6
- data/app/helpers/utility_helper.rb +2 -3
- data/app/views/layouts/application.html.erb +3 -2
- data/app/views/layouts/application.html.haml +3 -2
- data/lib/dry_crud/engine.rb +8 -4
- data/lib/generators/dry_crud/dry_crud_generator.rb +1 -1
- data/lib/generators/dry_crud/templates/spec/support/crud_controller_examples.rb +0 -8
- data/lib/generators/dry_crud/templates/spec/support/crud_controller_test_helper.rb +1 -1
- data/lib/generators/dry_crud/templates/test/support/crud_test_helper.rb +15 -6
- metadata +5 -5
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 3ff2a042dc7c846957d5e17001f9a538df726084e3695988d68066849938d544
         | 
| 4 | 
            +
              data.tar.gz: 504a97b4e2b0769cb260790725bb1a59aaffe33a16a093556d9462dd2403794f
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 9808508def34a37d4d7bea43c5e7d810a4ac57d09c36ceadf8ee0fbf5bba3650611c5e3c5b010f5aa015666076ac3971fe824f2d6deeb17d913cc4404d2261bd
         | 
| 7 | 
            +
              data.tar.gz: c9b52ac7b06f5ab74f4fc3b8b0f340f1e3e5f35296296d109585dcb51906b46eb9615c393865cdde30aefb096dabf41dac197a24dc8e364d57e071551fbb0e5e
         | 
    
        data/README.rdoc
    CHANGED
    
    | @@ -1,6 +1,6 @@ | |
| 1 1 | 
             
            = DRY CRUD
         | 
| 2 2 |  | 
| 3 | 
            -
            {<img src="https:// | 
| 3 | 
            +
            {<img src="https://travis-ci.org/codez/dry_crud.svg?branch=master" />}[http://travis-ci.org/codez/dry_crud]
         | 
| 4 4 |  | 
| 5 5 | 
             
            dry_crud generates simple and extendable controllers, views and helpers that support you to DRY up the CRUD code in your Rails projects. List, search, sort, show, create, edit and destroy any model entries in just 5 minutes. Start with these artifacts and build a clean base to efficiently develop your application upon.
         | 
| 6 6 |  | 
| @@ -21,7 +21,7 @@ We recommend to use dry_crud as a generator as described above for the best unde | |
| 21 21 |  | 
| 22 22 | 
             
              rails generate dry_crud:file list/index.html.erb
         | 
| 23 23 |  | 
| 24 | 
            -
            If a dry_crud file exists in your application, it will be used, if not, the one from the engine is used. This holds for controllers,  | 
| 24 | 
            +
            If a dry_crud file exists in your application, it will be used, if not, the one from the engine is used. This holds for controllers, helper methods and view templates.
         | 
| 25 25 |  | 
| 26 26 |  | 
| 27 27 | 
             
            == Integration
         | 
| @@ -33,12 +33,12 @@ To integrate dry_crud into your code, only a few additions are required: | |
| 33 33 | 
             
            * Optionally define a +list+ scope in your models to be used in the +index+ action.
         | 
| 34 34 | 
             
            * Optionally define a +options_list+ scope in your models to be used in select dropdowns.
         | 
| 35 35 |  | 
| 36 | 
            -
            From version 5.0 onwards, the major and minor version numbers will be kept in sync with Rails, and only the matching Rails version is supported. Version 3.0 is compatible 4.2, Version 2.0 and higher are compatible with Rails 4 and Rails 3.2. dry_crud is tested with Ruby 2. | 
| 36 | 
            +
            From version 5.0 onwards, the major and minor version numbers will be kept in sync with Rails, and only the matching Rails version is supported. Version 3.0 is compatible 4.2, Version 2.0 and higher are compatible with Rails 4 and Rails 3.2. dry_crud is tested with Ruby 2.5. If you are using Ruby 1.9.3, please refer to version 3.0.0.
         | 
| 37 37 |  | 
| 38 38 |  | 
| 39 39 | 
             
            == Background
         | 
| 40 40 |  | 
| 41 | 
            -
            In most Rails applications, you have some models that require basic CRUD (create, read, update, delete) functionality. There are various possibilities like Rails scaffolding, {Inherited Resources}[https://github.com/ | 
| 41 | 
            +
            In most Rails applications, you have some models that require basic CRUD (create, read, update, delete) functionality. There are various possibilities like Rails scaffolding, {Inherited Resources}[https://github.com/activeadmin/inherited_resources] or {Rails Admin}[https://github.com/sferik/rails_admin]. Still, various parts in your application remain duplicated. While you might pull up common methods into a common superclass controller, most views still contain very similar code. And then you also have to remember the entire API of these frameworks.
         | 
| 42 42 |  | 
| 43 43 | 
             
            Enter dry_crud.
         | 
| 44 44 |  | 
| @@ -46,11 +46,11 @@ Enter dry_crud. | |
| 46 46 | 
             
            The main idea of dry_crud is to concentrate basic functionality of your application, like CRUD actions, uniform formatting, forms and tables into specifically extendable units. dry_crud generates various foundation classes that you may browse easily and adapt freely to your application's needs. For each model, you may transparently customize arbitrary parts or just fallback to the general behavior. This applies not only for controllers, but also for view templates and helpers. There is no black box your code depends on. You lay the foundation that fits your application best.
         | 
| 47 47 | 
             
            </b>
         | 
| 48 48 |  | 
| 49 | 
            -
            dry_crud is a Rails generator. All code resides in your application and is open for you to inspect and to extend. You may pick whatever you consider useful or adapt what is not sufficient. Even if you do not require any CRUD functionality, you might find some helpers simplifying your work. There are no runtime dependencies to the dry_crud gem. Having said this, dry_crud does not want to provide a maximum of functionality that requires a lot of configuration, but rather a clean and lightweight foundation to build your application's requirements upon. This is why dry_crud comes as a generator and not as a Rails  | 
| 49 | 
            +
            dry_crud is a Rails generator. All code resides in your application and is open for you to inspect and to extend. You may pick whatever you consider useful or adapt what is not sufficient. Even if you do not require any CRUD functionality, you might find some helpers simplifying your work. There are no runtime dependencies to the dry_crud gem. Having said this, dry_crud does not want to provide a maximum of functionality that requires a lot of configuration, but rather a clean and lightweight foundation to build your application's requirements upon. This is why dry_crud comes as a generator and not as a Rails extension.
         | 
| 50 50 |  | 
| 51 | 
            -
            dry_crud does not depend on any other  | 
| 51 | 
            +
            dry_crud does not depend on any other gems, but easily allows you to integrate them in order to unify the behavior of your CRUD controllers. You might even use the gems mentioned above to adapt your generated CrudController base class. All classes come with thorough tests that provide you with a solid foundation for implementing your own adaptions.
         | 
| 52 52 |  | 
| 53 | 
            -
            A basic CSS gets you started with your application's layout. For advanced needs, dry_crud supports the styles and classes used in {Bootstrap  | 
| 53 | 
            +
            A basic CSS gets you started with your application's layout. For advanced needs, dry_crud supports the styles and classes used in {Bootstrap 4}[http://getbootstrap.com]. A great design never was so close.
         | 
| 54 54 |  | 
| 55 55 | 
             
            If you find yourself adapting the same parts of dry_crud for your applications over and over, please feel free to {fork me on Github}[http://github.com/codez/dry_crud].
         | 
| 56 56 |  | 
| @@ -66,7 +66,7 @@ Say you want to manage a +Person+ model. Overwrite the +to_s+ method of your mod | |
| 66 66 | 
             
            <tt>app/models/person.rb</tt>:
         | 
| 67 67 | 
             
              class Person
         | 
| 68 68 | 
             
                def to_s
         | 
| 69 | 
            -
                   | 
| 69 | 
            +
                  [lastname, firstname].compact.join(' ')
         | 
| 70 70 | 
             
                end
         | 
| 71 71 | 
             
              end
         | 
| 72 72 |  | 
| @@ -74,7 +74,7 @@ Then create the following controller. The +permitted_attrs+ define the attribute | |
| 74 74 |  | 
| 75 75 | 
             
            <tt>app/controllers/people_controller.rb</tt>:
         | 
| 76 76 | 
             
              class PeopleController < CrudController
         | 
| 77 | 
            -
                self.permitted_attrs = [:firstname, :lastname, :birthday, : | 
| 77 | 
            +
                self.permitted_attrs = [:firstname, :lastname, :birthday, :gender, :city_id]
         | 
| 78 78 | 
             
              end
         | 
| 79 79 |  | 
| 80 80 | 
             
            That's it. You have a sortable overview of all people, detail pages and forms to edit and create people. Of course, you may delete people as well. By default, all attributes are displayed and formatted according to their column type wherever they appear. This applies for the input fields as well.
         | 
| @@ -84,14 +84,14 @@ That's it. You have a sortable overview of all people, detail pages and forms to | |
| 84 84 |  | 
| 85 85 | 
             
            Well, maybe there are certain attributes you do not want to display in the people list, or others that are not editable in the form. No problem, simply create a <tt> _list</tt> partial in <tt>app/views/people/_list.html.erb</tt> to customize this:
         | 
| 86 86 |  | 
| 87 | 
            -
              <%= crud_table :lastname, :firstname, :city, : | 
| 87 | 
            +
              <%= crud_table :lastname, :firstname, :city, :gender %>
         | 
| 88 88 |  | 
| 89 89 | 
             
            This only displays these four attributes in the table. All other templates, as well as the main index view, fallback to the ones in <tt>app/views/crud</tt>.
         | 
| 90 90 |  | 
| 91 91 |  | 
| 92 92 | 
             
            ==== Adapt general behavior
         | 
| 93 93 |  | 
| 94 | 
            -
            Next, let's adapt a part of the general behavior used in all CRUD controllers. As an example, we include pagination with kaminari[https://github.com/ | 
| 94 | 
            +
            Next, let's adapt a part of the general behavior used in all CRUD controllers. As an example, we include pagination with kaminari[https://github.com/kaminari/kaminari] in all our overview tables:
         | 
| 95 95 |  | 
| 96 96 | 
             
            In <tt>app/controllers/list_controller.rb</tt>, change the list_entries method to
         | 
| 97 97 | 
             
              def list_entries
         | 
| @@ -106,11 +106,11 @@ And we are done. All our controllers inheriting from ListController, including a | |
| 106 106 |  | 
| 107 107 | 
             
            ==== Special formatting for selected attributes
         | 
| 108 108 |  | 
| 109 | 
            -
            Sometimes, the default formatting provided by +format_attr+ will not be sufficient. We have a boolean column + | 
| 109 | 
            +
            Sometimes, the default formatting provided by +format_attr+ will not be sufficient. We have a boolean column +female+ in our model (which is quite a legacy nowadays!), but we would like to display 'male' or 'female' for it (instead of 'no' or 'yes', which is a bit cryptic). Just define a method in your view helper starting with <tt>format_</tt>, followed by the class and attribute name:
         | 
| 110 110 |  | 
| 111 111 | 
             
            In <tt>app/helpers/people.rb</tt>:
         | 
| 112 | 
            -
              def  | 
| 113 | 
            -
                person. | 
| 112 | 
            +
              def format_person_female(person)
         | 
| 113 | 
            +
                person.female ? 'female' : 'male'
         | 
| 114 114 | 
             
              end
         | 
| 115 115 |  | 
| 116 116 | 
             
            Should you have attributes with the same name for multiple models that you want to be formatted the same way, you may define a helper method <tt>format_{attr}</tt> for these attributes.
         | 
| @@ -133,7 +133,7 @@ In <tt>app/controllers/people_controller.rb</tt>: | |
| 133 133 | 
             
            When you display computed values in your list table, you may define sort mappings to enable sorting of these columns:
         | 
| 134 134 |  | 
| 135 135 | 
             
            In <tt>app/controllers/people_controller.rb</tt>:
         | 
| 136 | 
            -
              self.sort_mappings = {age: 'birthday', city_id: 'cities.name'}
         | 
| 136 | 
            +
              self.sort_mappings = { age: 'birthday', city_id: 'cities.name' }
         | 
| 137 137 |  | 
| 138 138 | 
             
            There is also a simple search functionality (based on SQL LIKE queries) implemented in Crud::Searchable. Define an array of columns in your controller's +search_columns+ class variable to make the entries searchable by these fields:
         | 
| 139 139 |  | 
| @@ -151,17 +151,17 @@ dry_crud provides two builder classes for update/create forms and tables for dis | |
| 151 151 |  | 
| 152 152 | 
             
            The following code defines a table with some attribute columns for a list of same-type entries. Columns get a header corresponding to the attribute name:
         | 
| 153 153 | 
             
              <%= plain_table(@people) do |t|
         | 
| 154 | 
            -
                    t.sortable_attrs | 
| 154 | 
            +
                    t.sortable_attrs(:lastname, :firstname)
         | 
| 155 155 | 
             
                  end %>
         | 
| 156 156 |  | 
| 157 157 | 
             
            If entries is empty, a basic 'No entries found' message is rendered instead of the table.
         | 
| 158 158 |  | 
| 159 159 | 
             
            To render custom columns, use the +col+ method with an appropriate block:
         | 
| 160 160 | 
             
              <%= plain_table(@people) do |t|
         | 
| 161 | 
            -
                    t.sortable_attrs | 
| 162 | 
            -
                    t.col('', class: 'center') {|entry| image_tag(entry.picture) }
         | 
| 163 | 
            -
                    t.attr | 
| 164 | 
            -
                    t.col('Map') {|entry| link_to(entry.city, "http://maps.google.com/?q=#{entry.city}" }
         | 
| 161 | 
            +
                    t.sortable_attrs(:lastname, :firstname)
         | 
| 162 | 
            +
                    t.col('', class: 'center') { |entry| image_tag(entry.picture) }
         | 
| 163 | 
            +
                    t.attr(:street)
         | 
| 164 | 
            +
                    t.col('Map') { |entry| link_to(entry.city, "http://maps.google.com/?q=#{entry.city}" }
         | 
| 165 165 | 
             
                  end %>
         | 
| 166 166 |  | 
| 167 167 | 
             
            For views of subclasses of ListController, you can directly use the +crud_table+ helper method, where you do not have to pass the <tt>@people</tt> list explicitly and actions are added automatically.
         | 
| @@ -175,9 +175,9 @@ Forms work very similar. In the most simple case, you just have to specify which | |
| 175 175 | 
             
            Of course, custom input fields may be defined as well:
         | 
| 176 176 | 
             
              <%= standard_form(@person, url: custom_update_person_path(@person.id)) do |f| %>
         | 
| 177 177 | 
             
                <%= f.labeled_input_fields :firstname, :lastname %>
         | 
| 178 | 
            -
                <%= f.labeled(: | 
| 179 | 
            -
                  <%= f.radio_button : | 
| 180 | 
            -
                  <%= f.radio_button : | 
| 178 | 
            +
                <%= f.labeled(:female) do %>
         | 
| 179 | 
            +
                  <%= f.radio_button :female, true %> female
         | 
| 180 | 
            +
                  <%= f.radio_button :female, false %> male
         | 
| 181 181 | 
             
                <% end %>
         | 
| 182 182 | 
             
                <%= f.labeled_integer_field :age %>
         | 
| 183 183 | 
             
                <%= f.labeled_file_field :picture %>
         | 
| @@ -193,7 +193,7 @@ Optionally, +has_and_belongs_to_many+ and +has_many+ associations can be rendere | |
| 193 193 |  | 
| 194 194 | 
             
            And yes again, the same advice for where to put finder logic applies here as well.
         | 
| 195 195 |  | 
| 196 | 
            -
            <b>Note:</b> +has_and_belongs_to_many+ and +has_many+ associations are not automatically rendered in a form, you have to explicitly include these attributes. You might also want to stylize the multi-select widget | 
| 196 | 
            +
            <b>Note:</b> +has_and_belongs_to_many+ and +has_many+ associations are not automatically rendered in a form, you have to explicitly include these attributes. You might also want to stylize the multi-select widget with a JavaScript library of your choice.
         | 
| 197 197 |  | 
| 198 198 |  | 
| 199 199 | 
             
            === Nested Resources
         | 
| @@ -221,8 +221,8 @@ In <tt>app/controllers/people_controller.rb</tt>: | |
| 221 221 |  | 
| 222 222 | 
             
              def delete_picture
         | 
| 223 223 | 
             
                if !perform_delete_picture(entry.picture)
         | 
| 224 | 
            -
                  flash | 
| 225 | 
            -
                   | 
| 224 | 
            +
                  flash[:alert] = 'Could not delete picture'
         | 
| 225 | 
            +
                  throw :abort
         | 
| 226 226 | 
             
                end
         | 
| 227 227 | 
             
              end
         | 
| 228 228 |  | 
| @@ -269,49 +269,49 @@ All generated files are supposed to provide a reasonable foundation for the CRUD | |
| 269 269 |  | 
| 270 270 | 
             
            === Controller
         | 
| 271 271 |  | 
| 272 | 
            -
            {controller/crud_controller.rb}[ | 
| 272 | 
            +
            {controller/crud_controller.rb}[https://rubydoc.info/github/codez/dry_crud/master/CrudController]:: Abstract controller providing basic CRUD actions. This implementation mainly follows the one of the Rails scaffolding controller and responses to HTML and JSON requests. Some enhancements were made to ease extendability. Several protected helper methods are there to be (optionally) overriden by subclasses. With the help of additional callbacks, it is possible to hook into the action procedures without overriding the entire method. This class is based on ListController.
         | 
| 273 273 |  | 
| 274 | 
            -
            {controller/list_controller.rb}[ | 
| 274 | 
            +
            {controller/list_controller.rb}[https://rubydoc.info/github/codez/dry_crud/master/ListController]:: Abstract controller providing a basic list action. Use this controller if you require read-only functionality. It includes the following modules.
         | 
| 275 275 |  | 
| 276 | 
            -
            {controller/dry_crud/generic_model.rb}[ | 
| 276 | 
            +
            {controller/dry_crud/generic_model.rb}[https://rubydoc.info/github/codez/dry_crud/master/DryCrud/GenericModel]:: Work with the model whose name corrsponds to the controller's name.
         | 
| 277 277 |  | 
| 278 | 
            -
            {controller/dry_crud/nestable.rb}[ | 
| 278 | 
            +
            {controller/dry_crud/nestable.rb}[https://rubydoc.info/github/codez/dry_crud/master/DryCrud/Nestable]:: Provides functionality to easily nest controllers/resources.
         | 
| 279 279 |  | 
| 280 | 
            -
            {controller/dry_crud/rememberable.rb}[ | 
| 280 | 
            +
            {controller/dry_crud/rememberable.rb}[https://rubydoc.info/github/codez/dry_crud/master/DryCrud/Rememberable]:: Remembers certain params of the index action in order to return to the same list after an entry was viewed or edited.
         | 
| 281 281 |  | 
| 282 | 
            -
            {controller/dry_crud/searchable.rb}[ | 
| 282 | 
            +
            {controller/dry_crud/searchable.rb}[https://rubydoc.info/github/codez/dry_crud/master/DryCrud/Searchable]:: Search functionality for the index table.
         | 
| 283 283 |  | 
| 284 | 
            -
            {controller/dry_crud/sortable.rb}[ | 
| 284 | 
            +
            {controller/dry_crud/sortable.rb}[https://rubydoc.info/github/codez/dry_crud/master/DryCrud/Sortable]:: Sort functionality for the index table.
         | 
| 285 285 |  | 
| 286 | 
            -
            {controller/dry_crud/render_callbacks.rb}[ | 
| 286 | 
            +
            {controller/dry_crud/render_callbacks.rb}[https://rubydoc.info/github/codez/dry_crud/master/DryCrud/RenderCallbacks]:: Provide +before_render+ callbacks to controllers.
         | 
| 287 287 |  | 
| 288 | 
            -
            {controller/dry_crud/responder.rb}[ | 
| 288 | 
            +
            {controller/dry_crud/responder.rb}[https://rubydoc.info/github/codez/dry_crud/master/DryCrud/Responder]:: Responder used by the CrudController to handle the +path_args+.
         | 
| 289 289 |  | 
| 290 290 | 
             
            === Helpers
         | 
| 291 291 |  | 
| 292 | 
            -
            {helpers/dry_crud/form/builder.rb}[ | 
| 292 | 
            +
            {helpers/dry_crud/form/builder.rb}[https://rubydoc.info/github/codez/dry_crud/master/DryCrud/Form/Builder]:: A form builder that automatically selects the corresponding input type for ActiveRecord columns. Input elements are rendered together with a label by default.
         | 
| 293 293 |  | 
| 294 | 
            -
            {helpers/dry_crud/form/control.rb}[ | 
| 294 | 
            +
            {helpers/dry_crud/form/control.rb}[https://rubydoc.info/github/codez/dry_crud/master/DryCrud/Form/Control]:: Representation of a single form control consisting of a label, input field, addon or help text.
         | 
| 295 295 |  | 
| 296 | 
            -
            {helpers/dry_crud/table/builder.rb}[ | 
| 296 | 
            +
            {helpers/dry_crud/table/builder.rb}[https://rubydoc.info/github/codez/dry_crud/master/DryCrud/Table/Builder]:: A helper object to easily define tables listing several rows of the same data type.
         | 
| 297 297 |  | 
| 298 | 
            -
            {helpers/dry_crud/table/col.rb}[ | 
| 298 | 
            +
            {helpers/dry_crud/table/col.rb}[https://rubydoc.info/github/codez/dry_crud/master/DryCrud/Table/Col]:: Helper class representing a single table column.
         | 
| 299 299 |  | 
| 300 | 
            -
            {helpers/dry_crud/table/actions.rb}[ | 
| 300 | 
            +
            {helpers/dry_crud/table/actions.rb}[https://rubydoc.info/github/codez/dry_crud/master/DryCrud/Table/Actions]:: Module to add support for uniform CRUD actions in tables.
         | 
| 301 301 |  | 
| 302 | 
            -
            {helpers/dry_crud/table/sorting.rb}[ | 
| 302 | 
            +
            {helpers/dry_crud/table/sorting.rb}[https://rubydoc.info/github/codez/dry_crud/master/DryCrud/Table/Sorting]:: Module to add support for sort links in table headers.
         | 
| 303 303 |  | 
| 304 | 
            -
            {helpers/form_helper.rb}[ | 
| 304 | 
            +
            {helpers/form_helper.rb}[https://rubydoc.info/github/codez/dry_crud/master/FormHelper]:: Create forms to edit models with Crud::FormBuilder. Contains a standardized and a custom definable form.
         | 
| 305 305 |  | 
| 306 | 
            -
            {helpers/table_helper.rb}[ | 
| 306 | 
            +
            {helpers/table_helper.rb}[https://rubydoc.info/github/codez/dry_crud/master/TableHelper]:: Create tables to list multiple models with Crud::TableBuilder. Contains a standardized and a custom definable table.
         | 
| 307 307 |  | 
| 308 | 
            -
            {helpers/format_helper.rb}[ | 
| 308 | 
            +
            {helpers/format_helper.rb}[https://rubydoc.info/github/codez/dry_crud/master/FormatHelper]:: Format attribute and basic values according to their database or Ruby type.
         | 
| 309 309 |  | 
| 310 | 
            -
            {helpers/actions_helper.rb}[ | 
| 310 | 
            +
            {helpers/actions_helper.rb}[https://rubydoc.info/github/codez/dry_crud/master/ActionsHelper]:: Uniform action links for the most common crud actions.
         | 
| 311 311 |  | 
| 312 | 
            -
            {helpers/i18n_helper.rb}[ | 
| 312 | 
            +
            {helpers/i18n_helper.rb}[https://rubydoc.info/github/codez/dry_crud/master/I18nHelper]:: Translation helpers extending Rails' +translate+ helper to support translation inheritance over the controller class hierarchy.
         | 
| 313 313 |  | 
| 314 | 
            -
            {helpers/utility_helper.rb}[ | 
| 314 | 
            +
            {helpers/utility_helper.rb}[https://rubydoc.info/github/codez/dry_crud/master/UtilityHelper]:: View helpers for basic functions used in various other helpers.
         | 
| 315 315 |  | 
| 316 316 |  | 
| 317 317 |  | 
| @@ -372,9 +372,9 @@ app/assets/images/action/*.png:: Some sample action icons from the {Open Icon Li | |
| 372 372 |  | 
| 373 373 | 
             
            test/support/crud_test_model.rb:: A dummy model to run CRUD tests against.
         | 
| 374 374 |  | 
| 375 | 
            -
            {test/support/custom_assertions.rb}[ | 
| 375 | 
            +
            {test/support/custom_assertions.rb}[https://rubydoc.info/github/codez/dry_crud/master/CustomAssertions]:: A handful of convenient assertions. Include this module into your <tt>test_helper.rb</tt> file.
         | 
| 376 376 |  | 
| 377 | 
            -
            {test/support/crud_controller_test_helper.rb}[ | 
| 377 | 
            +
            {test/support/crud_controller_test_helper.rb}[https://rubydoc.info/github/codez/dry_crud/master/CrudControllerTestHelper]:: A module to include into the functional tests for your CrudController subclasses. Contains a handful of CRUD functionality tests for the provided implementation. So for each new CRUD controller, you get 20 tests for free.
         | 
| 378 378 |  | 
| 379 379 | 
             
            test/controllers/crud_test_models_controller_test.rb:: Functional tests for the basic CrudController functionality.
         | 
| 380 380 |  | 
| @@ -385,7 +385,7 @@ test/helpers/*_test.rb:: Tests for the provided helper implementations and a gre | |
| 385 385 |  | 
| 386 386 | 
             
            spec/support/crud_controller_examples.rb:: A whole set of shared exampled to include into your controller specs. See <tt>spec/controllers/crud_test_models_controller_spec.rb</tt> for usage. So for each new CRUD controller, you get all the basic specs for free.
         | 
| 387 387 |  | 
| 388 | 
            -
            {spec/support/crud_controller_test_helper.rb}[ | 
| 388 | 
            +
            {spec/support/crud_controller_test_helper.rb}[https://rubydoc.info/github/codez/dry_crud/master/CrudControllerTestHelper/ClassMethods]:: Convenience methods used by the crud controller examples.
         | 
| 389 389 |  | 
| 390 390 | 
             
            spec/support/crud_test_model.rb:: A dummy model to run CRUD tests against.
         | 
| 391 391 |  | 
    
        data/VERSION
    CHANGED
    
    | @@ -1 +1 @@ | |
| 1 | 
            -
             | 
| 1 | 
            +
            6.0.0
         | 
| @@ -73,9 +73,7 @@ module DryCrud | |
| 73 73 | 
             
                  def boolean_field(attr, html_options = {})
         | 
| 74 74 | 
             
                    content_tag(:div, class: 'checkbox') do
         | 
| 75 75 | 
             
                      content_tag(:label) do
         | 
| 76 | 
            -
                        # rubocop:disable Rails/OutputSafety
         | 
| 77 76 | 
             
                        detail = html_options.delete(:detail) || ' '.html_safe
         | 
| 78 | 
            -
                        # rubocop:enable Rails/OutputSafety
         | 
| 79 77 | 
             
                        safe_join([check_box(attr, html_options), ' ', detail])
         | 
| 80 78 | 
             
                      end
         | 
| 81 79 | 
             
                    end
         | 
| @@ -90,6 +88,22 @@ module DryCrud | |
| 90 88 | 
             
                    end
         | 
| 91 89 | 
             
                  end
         | 
| 92 90 |  | 
| 91 | 
            +
                  def integer_field(attr, html_options = {})
         | 
| 92 | 
            +
                    html_options[:step] ||= 1
         | 
| 93 | 
            +
                    number_field(attr, html_options)
         | 
| 94 | 
            +
                  end
         | 
| 95 | 
            +
             | 
| 96 | 
            +
                  def float_field(attr, html_options = {})
         | 
| 97 | 
            +
                    html_options[:step] ||= 'any'
         | 
| 98 | 
            +
                    number_field(attr, html_options)
         | 
| 99 | 
            +
                  end
         | 
| 100 | 
            +
             | 
| 101 | 
            +
                  def decimal_field(attr, html_options = {})
         | 
| 102 | 
            +
                    html_options[:step] ||=
         | 
| 103 | 
            +
                      (10**-column_property(object, attr, :scale)).to_f
         | 
| 104 | 
            +
                    number_field(attr, html_options)
         | 
| 105 | 
            +
                  end
         | 
| 106 | 
            +
             | 
| 93 107 | 
             
                  # Customize the standard text area to have 5 rows by default.
         | 
| 94 108 | 
             
                  def text_area(attr, html_options = {})
         | 
| 95 109 | 
             
                    add_css_class(html_options, 'form-control')
         | 
| @@ -97,10 +111,6 @@ module DryCrud | |
| 97 111 | 
             
                    super(attr, html_options)
         | 
| 98 112 | 
             
                  end
         | 
| 99 113 |  | 
| 100 | 
            -
                  alias integer_field number_field
         | 
| 101 | 
            -
                  alias float_field number_field
         | 
| 102 | 
            -
                  alias decimal_field number_field
         | 
| 103 | 
            -
             | 
| 104 114 | 
             
                  # Render a select element for a :belongs_to association defined by attr.
         | 
| 105 115 | 
             
                  # Use additional html_options for the select element.
         | 
| 106 116 | 
             
                  # To pass a custom element list, specify the list with the :list key or
         | 
| @@ -3,9 +3,8 @@ require 'English' | |
| 3 3 | 
             
            # View helpers for basic functions used in various other helpers.
         | 
| 4 4 | 
             
            module UtilityHelper
         | 
| 5 5 |  | 
| 6 | 
            -
              #  | 
| 7 | 
            -
              EMPTY_STRING = ' '.html_safe | 
| 8 | 
            -
              # rubocop:enable Rails/OutputSafety
         | 
| 6 | 
            +
              # non-breaking space asserts better css.
         | 
| 7 | 
            +
              EMPTY_STRING = ' '.html_safe.freeze
         | 
| 9 8 |  | 
| 10 9 | 
             
              # Render a content tag with the collected contents rendered
         | 
| 11 10 | 
             
              # by &block for each item in collection.
         | 
| @@ -7,9 +7,10 @@ | |
| 7 7 |  | 
| 8 8 | 
             
              <meta name="viewport" content="width=device-width, initial-scale=1.0">
         | 
| 9 9 | 
             
              <%= csrf_meta_tag %>
         | 
| 10 | 
            +
              <%= csp_meta_tag %>
         | 
| 10 11 |  | 
| 11 | 
            -
              <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track'  | 
| 12 | 
            -
              <%=  | 
| 12 | 
            +
              <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
         | 
| 13 | 
            +
              <%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
         | 
| 13 14 |  | 
| 14 15 | 
             
              <%= yield :head %>
         | 
| 15 16 | 
             
            </head>
         | 
| @@ -9,9 +9,10 @@ | |
| 9 9 |  | 
| 10 10 | 
             
                %meta{name: 'viewport', content: 'width=device-width, initial-scale=1.0'}
         | 
| 11 11 | 
             
                = csrf_meta_tag
         | 
| 12 | 
            +
                = csp_meta_tag
         | 
| 12 13 |  | 
| 13 | 
            -
                = stylesheet_link_tag 'application', :media => 'all', 'data-turbolinks-track'  | 
| 14 | 
            -
                =  | 
| 14 | 
            +
                = stylesheet_link_tag 'application', :media => 'all', 'data-turbolinks-track': 'reload'
         | 
| 15 | 
            +
                = javascript_pack_tag 'application', 'data-turbolinks-track': 'reload'
         | 
| 15 16 |  | 
| 16 17 | 
             
                = yield :head
         | 
| 17 18 |  | 
    
        data/lib/dry_crud/engine.rb
    CHANGED
    
    | @@ -1,14 +1,17 @@ | |
| 1 1 | 
             
            module DryCrud
         | 
| 2 2 | 
             
              # Dry Crud Rails engine
         | 
| 3 3 | 
             
              class Engine < Rails::Engine
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                # Fields with errors are directly styled in DryCrud::FormBuilder.
         | 
| 6 | 
            +
                # Rails should just output the plain html tag.
         | 
| 4 7 | 
             
                initializer 'dry_crud.field_error_proc' do |_app|
         | 
| 5 | 
            -
                  # Fields with errors are directly styled in DryCrud::FormBuilder.
         | 
| 6 | 
            -
                  # Rails should just output the plain html tag.
         | 
| 7 8 | 
             
                  ActionView::Base.field_error_proc =
         | 
| 8 9 | 
             
                    proc { |html_tag, _instance| html_tag }
         | 
| 10 | 
            +
                end
         | 
| 9 11 |  | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 12 | 
            +
                # Load dry_crud engine helpers first so that the application may override
         | 
| 13 | 
            +
                # them.
         | 
| 14 | 
            +
                config.to_prepare do
         | 
| 12 15 | 
             
                  paths = ApplicationController.helpers_path
         | 
| 13 16 | 
             
                  helper_path = "#{File::SEPARATOR}app#{File::SEPARATOR}helpers"
         | 
| 14 17 | 
             
                  regexp = /dry_crud(-\d+\.\d+\.\d+)?#{helper_path}\z/
         | 
| @@ -18,5 +21,6 @@ module DryCrud | |
| 18 21 | 
             
                    paths.prepend(dry_crud_helpers)
         | 
| 19 22 | 
             
                  end
         | 
| 20 23 | 
             
                end
         | 
| 24 | 
            +
             | 
| 21 25 | 
             
              end
         | 
| 22 26 | 
             
            end
         | 
| @@ -43,11 +43,9 @@ shared_examples 'crud controller' do |options| | |
| 43 43 |  | 
| 44 44 | 
             
              describe_action :get, :index,
         | 
| 45 45 | 
             
                              unless: skip?(options, 'index') do
         | 
| 46 | 
            -
             | 
| 47 46 | 
             
                context '.html',
         | 
| 48 47 | 
             
                        format: :html,
         | 
| 49 48 | 
             
                        unless: skip?(options, %w[index html]) do
         | 
| 50 | 
            -
             | 
| 51 49 | 
             
                  context 'plain',
         | 
| 52 50 | 
             
                          unless: skip?(options, %w[index html plain]),
         | 
| 53 51 | 
             
                          combine: 'ihp' do
         | 
| @@ -110,11 +108,9 @@ shared_examples 'crud controller' do |options| | |
| 110 108 | 
             
              describe_action :get, :show,
         | 
| 111 109 | 
             
                              id: true,
         | 
| 112 110 | 
             
                              unless: skip?(options, 'show') do
         | 
| 113 | 
            -
             | 
| 114 111 | 
             
                context '.html',
         | 
| 115 112 | 
             
                        format: :html,
         | 
| 116 113 | 
             
                        unless: skip?(options, %w[show html]) do
         | 
| 117 | 
            -
             | 
| 118 114 | 
             
                  context 'plain',
         | 
| 119 115 | 
             
                          unless: skip?(options, %w[show html plain]),
         | 
| 120 116 | 
             
                          combine: 'sh' do
         | 
| @@ -254,7 +250,6 @@ shared_examples 'crud controller' do |options| | |
| 254 250 | 
             
                context '.json',
         | 
| 255 251 | 
             
                        format: :json,
         | 
| 256 252 | 
             
                        unless: skip?(options, %w[update json]) do
         | 
| 257 | 
            -
             | 
| 258 253 | 
             
                  context 'with valid params',
         | 
| 259 254 | 
             
                          unless: skip?(options, %w[update json valid]),
         | 
| 260 255 | 
             
                          combine: 'ujv' do
         | 
| @@ -278,7 +273,6 @@ shared_examples 'crud controller' do |options| | |
| 278 273 | 
             
              describe_action :delete, :destroy,
         | 
| 279 274 | 
             
                              id: true,
         | 
| 280 275 | 
             
                              unless: skip?(options, %w[destroy]) do
         | 
| 281 | 
            -
             | 
| 282 276 | 
             
                it 'removes entry from database', perform_request: false do
         | 
| 283 277 | 
             
                  expect { perform_request }.to change { model_class.count }.by(-1)
         | 
| 284 278 | 
             
                end
         | 
| @@ -286,7 +280,6 @@ shared_examples 'crud controller' do |options| | |
| 286 280 | 
             
                context '.html',
         | 
| 287 281 | 
             
                        format: :html,
         | 
| 288 282 | 
             
                        unless: skip?(options, %w[destroy html]) do
         | 
| 289 | 
            -
             | 
| 290 283 | 
             
                  context 'successfull', combine: 'dhs' do
         | 
| 291 284 | 
             
                    it_is_expected_to_redirect_to_index
         | 
| 292 285 | 
             
                    it_is_expected_to_have_flash(:notice)
         | 
| @@ -301,7 +294,6 @@ shared_examples 'crud controller' do |options| | |
| 301 294 | 
             
                context '.json',
         | 
| 302 295 | 
             
                        format: :json,
         | 
| 303 296 | 
             
                        unless: skip?(options, %w[destroy json]) do
         | 
| 304 | 
            -
             | 
| 305 297 | 
             
                  context 'successfull', combine: 'djs' do
         | 
| 306 298 | 
             
                    it_is_expected_to_respond(204)
         | 
| 307 299 | 
             
                    it { expect(response.body).to be_blank }
         | 
| @@ -1,8 +1,8 @@ | |
| 1 1 | 
             
            #:nodoc:
         | 
| 2 | 
            -
            REGEXP_ROWS = /<tr.+?<\/tr>/m | 
| 3 | 
            -
            REGEXP_HEADERS = /<th.+?<\/th>/m | 
| 4 | 
            -
            REGEXP_SORT_HEADERS = /<th.*?><a .*?sort_dir=asc.*?>.*?<\/a><\/th>/m | 
| 5 | 
            -
            REGEXP_ACTION_CELL = /<td class=\"action\"><a .*?href.+?<\/a><\/td>/m | 
| 2 | 
            +
            REGEXP_ROWS = /<tr.+?<\/tr>/m.freeze
         | 
| 3 | 
            +
            REGEXP_HEADERS = /<th.+?<\/th>/m.freeze
         | 
| 4 | 
            +
            REGEXP_SORT_HEADERS = /<th.*?><a .*?sort_dir=asc.*?>.*?<\/a><\/th>/m.freeze
         | 
| 5 | 
            +
            REGEXP_ACTION_CELL = /<td class=\"action\"><a .*?href.+?<\/a><\/td>/m.freeze
         | 
| 6 6 |  | 
| 7 7 | 
             
            # A simple test helper to prepare the test database with a CrudTestModel model.
         | 
| 8 8 | 
             
            # This helper is used to test the CrudController and various helpers
         | 
| @@ -128,8 +128,17 @@ module CrudTestHelper | |
| 128 128 | 
             
                routes = @routes
         | 
| 129 129 |  | 
| 130 130 | 
             
                controller.singleton_class.send(:include, routes.url_helpers)
         | 
| 131 | 
            -
             | 
| 132 | 
            -
             | 
| 131 | 
            +
             | 
| 132 | 
            +
                if controller.respond_to?(:view_context_class)
         | 
| 133 | 
            +
                  view_context_class = Class.new(controller.view_context_class) do
         | 
| 134 | 
            +
                    include routes.url_helpers
         | 
| 135 | 
            +
                  end
         | 
| 136 | 
            +
                  custom_view_context = Module.new do
         | 
| 137 | 
            +
                    define_method(:view_context_class) do
         | 
| 138 | 
            +
                      view_context_class
         | 
| 139 | 
            +
                    end
         | 
| 140 | 
            +
                  end
         | 
| 141 | 
            +
                  controller.extend(custom_view_context)
         | 
| 133 142 | 
             
                end
         | 
| 134 143 |  | 
| 135 144 | 
             
                @routes.draw { resources :crud_test_models }
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: dry_crud
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version:  | 
| 4 | 
            +
              version: 6.0.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Pascal Zumkehr
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date:  | 
| 11 | 
            +
            date: 2019-09-08 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: rails
         | 
| @@ -16,14 +16,14 @@ dependencies: | |
| 16 16 | 
             
                requirements:
         | 
| 17 17 | 
             
                - - ">="
         | 
| 18 18 | 
             
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            -
                    version: ' | 
| 19 | 
            +
                    version: '6.0'
         | 
| 20 20 | 
             
              type: :runtime
         | 
| 21 21 | 
             
              prerelease: false
         | 
| 22 22 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 23 23 | 
             
                requirements:
         | 
| 24 24 | 
             
                - - ">="
         | 
| 25 25 | 
             
                  - !ruby/object:Gem::Version
         | 
| 26 | 
            -
                    version: ' | 
| 26 | 
            +
                    version: '6.0'
         | 
| 27 27 | 
             
            description: |
         | 
| 28 28 | 
             
              Generates simple and extendable controller, views and helpers that support you
         | 
| 29 29 | 
             
              to DRY up the CRUD code in your Rails project. Start with these elements and
         | 
| @@ -139,7 +139,7 @@ files: | |
| 139 139 | 
             
            - lib/generators/dry_crud/templates/test/support/crud_test_model.rb
         | 
| 140 140 | 
             
            - lib/generators/dry_crud/templates/test/support/crud_test_models_controller.rb
         | 
| 141 141 | 
             
            - lib/generators/dry_crud/templates/test/support/custom_assertions.rb
         | 
| 142 | 
            -
            homepage: http:// | 
| 142 | 
            +
            homepage: http://github.com/codez/dry_crud
         | 
| 143 143 | 
             
            licenses: []
         | 
| 144 144 | 
             
            metadata: {}
         | 
| 145 145 | 
             
            post_install_message: 
         |