├── .editorconfig ├── .github └── workflows │ └── test.yml ├── .gitignore ├── Gemfile ├── LICENSE ├── README.md ├── app ├── controllers │ └── custom_fields_groups_controller.rb ├── helpers │ └── custom_fields_groups_helper.rb ├── models │ ├── custom_fields_group.rb │ └── custom_fields_group_field.rb ├── overrides │ └── issues.rb └── views │ ├── custom_fields_groups │ ├── _custom_fields_group.html.erb │ ├── _form.html.erb │ ├── edit.html.erb │ ├── index.html.erb │ └── new.html.erb │ ├── issues │ └── _form_custom_fields.html.erb │ └── settings │ └── _redmine_custom_fields_groups.html.erb ├── assets ├── images │ ├── textfields_group.png │ └── textfields_group.xcf ├── javascripts │ └── custom_fields_groups.js └── stylesheets │ └── custom_fields_groups.css ├── config ├── locales │ ├── de.yml │ ├── en.yml │ └── ja.yml └── routes.rb ├── db └── migrate │ ├── 20211011081234_create_custom_fields_groups.rb │ ├── 20211011081244_create_custom_fields_group_fields.rb │ └── 20240409124454_add_on_delete_cascade_to_foreign_key_custom_field.rb ├── init.rb ├── lib ├── redmine_custom_fields_groups.rb └── redmine_custom_fields_groups │ ├── hooks │ ├── view_layouts_base_html_head_hook.rb │ └── view_user_preferences_hook.rb │ ├── options.rb │ └── patches │ ├── issues_helper_patch.rb │ └── user_preference_patch.rb └── test ├── fixtures ├── custom_fields_group_fields.yml └── custom_fields_groups.yml ├── functional └── custom_fields_groups_controller_test.rb ├── integration └── layout_test.rb ├── system └── fieldset_test.rb ├── test_helper.rb └── unit ├── custom_fields_group_field_test.rb └── custom_fields_group_test.rb /.editorconfig: -------------------------------------------------------------------------------- 1 | # editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = space 6 | indent_size = 2 7 | end_of_line = lf 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Test 2 | 3 | env: 4 | PLUGIN_NAME: ${{ github.event.repository.name }} 5 | 6 | on: 7 | push: 8 | branches: 9 | - main 10 | - next 11 | pull_request: 12 | branches: 13 | - main 14 | - next 15 | workflow_dispatch: 16 | 17 | jobs: 18 | test: 19 | name: redmine:${{ matrix.redmine_version }} ruby:${{ matrix.ruby_version }} db:${{ matrix.db }} 20 | runs-on: ubuntu-22.04 21 | 22 | strategy: 23 | fail-fast: false 24 | matrix: 25 | redmine_version: [4.2-stable, 5.0-stable, 5.1-stable, master] 26 | ruby_version: ['2.7', '3.0', '3.1', '3.2'] 27 | db: ['mysql:5.7', 'postgres:10', 'sqlite3'] 28 | # System test takes 2~3 times longer, so limit to specific matrix combinations 29 | # See: https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs#expanding-or-adding-matrix-configurations 30 | include: 31 | - system_test: true 32 | redmine_version: 5.1-stable 33 | ruby_version: '3.2' 34 | db: 'mysql:5.7' 35 | exclude: 36 | - redmine_version: 4.2-stable 37 | ruby_version: '3.0' 38 | - redmine_version: 4.2-stable 39 | ruby_version: '3.1' 40 | - redmine_version: 4.2-stable 41 | ruby_version: '3.2' 42 | - redmine_version: 5.0-stable 43 | ruby_version: '3.2' 44 | - redmine_version: master 45 | ruby_version: '2.7' 46 | 47 | steps: 48 | - name: Setup Redmine 49 | uses: hidakatsuya/action-setup-redmine@v1 50 | with: 51 | repository: redmine/redmine 52 | version: ${{ matrix.redmine_version }} 53 | ruby-version: ${{ matrix.ruby_version }} 54 | database: ${{ matrix.db }} 55 | path: redmine 56 | 57 | - name: Checkout Plugin 58 | uses: actions/checkout@v4 59 | with: 60 | path: redmine/plugins/${{ env.PLUGIN_NAME }} 61 | 62 | - name: Install Ruby dependencies 63 | working-directory: redmine 64 | run: | 65 | bundle config set --local without 'development' 66 | bundle install --jobs=4 --retry=3 67 | 68 | - name: Run Redmine rake tasks 69 | working-directory: redmine 70 | run: | 71 | bundle exec rake generate_secret_token 72 | bundle exec rake db:create db:migrate redmine:plugins:migrate 73 | 74 | - name: Zeitwerk check 75 | working-directory: redmine 76 | run: | 77 | if grep -q zeitwerk config/application.rb ; then 78 | bundle exec rake zeitwerk:check 79 | fi 80 | shell: bash 81 | 82 | - name: Run plugin tests 83 | working-directory: redmine 84 | run: | 85 | bundle exec rake redmine:plugins:test:units NAME=${{ env.PLUGIN_NAME }} RUBYOPT="-W0" 86 | bundle exec rake redmine:plugins:test:functionals NAME=${{ env.PLUGIN_NAME }} RUBYOPT="-W0" 87 | bundle exec rake redmine:plugins:test:integration NAME=${{ env.PLUGIN_NAME }} RUBYOPT="-W0" 88 | if [ ${{ matrix.system_test }} = "true" ]; then 89 | bundle exec rake redmine:plugins:test:system NAME=${{ env.PLUGIN_NAME }} RUBYOPT="-W0" 90 | fi 91 | 92 | # - name: Run core tests 93 | # env: 94 | # RAILS_ENV: test 95 | # PARALLEL_WORKERS: 1 96 | # working-directory: redmine 97 | # run: bundle exec rake test 98 | 99 | # - name: Run core system tests 100 | # if: matrix.system_test == true 101 | # env: 102 | # RAILS_ENV: test 103 | # GOOGLE_CHROME_OPTS_ARGS: "headless,disable-gpu,no-sandbox,disable-dev-shm-usage" 104 | # working-directory: redmine 105 | # run: bundle exec rake test:system 106 | 107 | - name: Run uninstall test 108 | working-directory: redmine 109 | run: bundle exec rake redmine:plugins:migrate NAME=${{ env.PLUGIN_NAME }} VERSION=0 110 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gem 'deface' 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | redmine_gtt 635 | Copyright (C) 2016 GTT 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | redmine_gtt Copyright (C) 2016 GTT 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Redmine Custom Fields Groups Plugin 2 | 3 | This is a plugin for grouping custom fields. 4 | 5 | ## Requirements 6 | 7 | - Redmine >= 4.0.0 8 | 9 | ## Installation 10 | 11 | To install Redmine Custom Fields Groups plugin, download or clone this repository in your Redmine installation plugins directory! 12 | 13 | ``` 14 | cd path/to/plugin/directory 15 | git clone https://github.com/gtt-project/redmine_custom_fields_groups.git 16 | ``` 17 | 18 | Then run 19 | 20 | ``` 21 | bundle install 22 | bundle exec rake redmine:plugins:migrate 23 | ``` 24 | 25 | After restarting Redmine, you should be able to see the Redmine Custom Fields Groups plugin in the Plugins page. 26 | 27 | More information on installing (and uninstalling) Redmine plugins can be found here: http://www.redmine.org/wiki/redmine/Plugins 28 | 29 | ## How to use 30 | 31 | TBD 32 | 33 | ## Contributing and Support 34 | 35 | The GTT Project appreciates any [contributions](https://github.com/gtt-project/.github/blob/main/CONTRIBUTING.md)! Feel free to contact us for [reporting problems and support](https://github.com/gtt-project/.github/blob/main/CONTRIBUTING.md). 36 | 37 | ## Version History 38 | 39 | See [all releases](https://github.com/gtt-project/redmine_custom_fields_groups/releases) with release notes. 40 | 41 | ## Authors 42 | 43 | - [Ko Nagase](https://github.com/sanak) 44 | - ... [and others](https://github.com/gtt-project/redmine_custom_fields_groups/graphs/contributors) 45 | 46 | ## LICENSE 47 | 48 | This program is free software. See [LICENSE](LICENSE) for more information. 49 | -------------------------------------------------------------------------------- /app/controllers/custom_fields_groups_controller.rb: -------------------------------------------------------------------------------- 1 | class CustomFieldsGroupsController < ApplicationController 2 | layout 'admin' 3 | 4 | before_action :require_admin 5 | before_action :find_custom_fields_group, only: %i[edit update destroy] 6 | 7 | def index 8 | @custom_fields_groups = CustomFieldsGroup.sorted 9 | end 10 | 11 | def new 12 | @custom_fields_group = CustomFieldsGroup.new 13 | end 14 | 15 | def create 16 | @custom_fields_group = CustomFieldsGroup.new 17 | @custom_fields_group.safe_attributes = custom_fields_group_params 18 | if @custom_fields_group.save 19 | flash[:notice] = l(:notice_successful_create) 20 | redirect_to custom_fields_groups_path 21 | else 22 | render :action => 'new' 23 | end 24 | end 25 | 26 | def edit 27 | end 28 | 29 | def update 30 | @custom_fields_group.safe_attributes = custom_fields_group_params 31 | if @custom_fields_group.save 32 | respond_to do |format| 33 | format.html do 34 | flash[:notice] = l(:notice_successful_update) 35 | redirect_to custom_fields_groups_path 36 | end 37 | format.js { head 200 } 38 | end 39 | else 40 | respond_to do |format| 41 | format.html { render :action => 'edit' } 42 | format.js { head 422 } 43 | end 44 | end 45 | end 46 | 47 | def destroy 48 | begin 49 | if @custom_fields_group.destroy 50 | flash[:notice] = l(:notice_successful_delete) 51 | end 52 | rescue 53 | flash[:error] = l(:error_can_not_delete_custom_fields_group) 54 | end 55 | redirect_to custom_fields_groups_path 56 | end 57 | 58 | private 59 | 60 | def custom_fields_group_params 61 | params.require(:custom_fields_group).permit(:name, :position, custom_field_ids: []) 62 | end 63 | 64 | def find_custom_fields_group 65 | @custom_fields_group = CustomFieldsGroup.find(params[:id]) 66 | rescue ActiveRecord::RecordNotFound 67 | render_404 68 | end 69 | end 70 | -------------------------------------------------------------------------------- /app/helpers/custom_fields_groups_helper.rb: -------------------------------------------------------------------------------- 1 | module CustomFieldsGroupsHelper 2 | # Referred: 3 | # - redmine/lib/redmine/field_format.rb 4 | # - def check_box_edit_tag 5 | # - redmine/app/helpers/custom_fields_helper.rb 6 | # - def custom_field_tag_with_label 7 | # - def custom_field_label_tag 8 | def group_fields_edit_tag(group, options={}) 9 | tag_id = 'custom_fields_group[custom_field_ids]' 10 | tag_name = 'custom_fields_group[custom_field_ids][]' 11 | opts = [] 12 | group_field_ids = group.custom_field_ids 13 | other_group_field_ids = CustomFieldsGroupField.all.collect { |gf| 14 | gf.custom_field_id 15 | } - group_field_ids 16 | opts += IssueCustomField.where.not(id: other_group_field_ids).sorted.collect do |cf| 17 | [cf.name, cf.id] 18 | end 19 | s = ''.html_safe 20 | opts.each do |label, value| 21 | value ||= label 22 | checked = group_field_ids.include?(value) 23 | tag = check_box_tag(tag_name, value, checked, :id => tag_id) 24 | s << content_tag('label', tag + ' ' + label) 25 | end 26 | s << hidden_field_tag(tag_name, '', :id => nil) 27 | css = "#{options[:class]} check_box_group" 28 | label = content_tag('label', l(:label_custom_field_plural), :for => tag_id) 29 | label + content_tag('span', s, options.merge(:class => css)) 30 | end 31 | end 32 | -------------------------------------------------------------------------------- /app/models/custom_fields_group.rb: -------------------------------------------------------------------------------- 1 | class CustomFieldsGroup < (defined?(ApplicationRecord) == 'constant' ? ApplicationRecord : ActiveRecord::Base) 2 | include Redmine::SafeAttributes 3 | 4 | validates :name, presence: true, uniqueness: true 5 | 6 | has_many :custom_fields_group_fields, :dependent => :delete_all 7 | has_many :custom_fields, :through => :custom_fields_group_fields 8 | 9 | acts_as_positioned 10 | scope :sorted, ->{ order :position } 11 | 12 | safe_attributes( 13 | 'name', 14 | 'position', 15 | 'custom_field_ids' 16 | ) 17 | end 18 | -------------------------------------------------------------------------------- /app/models/custom_fields_group_field.rb: -------------------------------------------------------------------------------- 1 | class CustomFieldsGroupField < ActiveRecord::Base 2 | belongs_to :custom_fields_group 3 | belongs_to :custom_field 4 | 5 | scope :sorted, (lambda do 6 | includes(:custom_field).order("#{CustomField.table_name}.position ASC") 7 | end) 8 | end 9 | -------------------------------------------------------------------------------- /app/overrides/issues.rb: -------------------------------------------------------------------------------- 1 | module Issues 2 | Deface::Override.new( 3 | :virtual_path => "issues/show", 4 | :name => "deface_replace_render_half_width_custom_fields_rows", 5 | :replace => "erb[loud]:contains('render_half_width_custom_fields_rows(@issue)')", 6 | :original => "<%= render_half_width_custom_fields_rows(@issue) %>", 7 | :text => "<%= render_custom_fields_rows_by_groups(@issue) %>" 8 | ) 9 | 10 | Deface::Override.new( 11 | :virtual_path => "issues/show", 12 | :name => "deface_remove_render_full_width_custom_fields_rows", 13 | :remove => "erb[loud]:contains('render_full_width_custom_fields_rows(@issue)')", 14 | :original => "<%= render_full_width_custom_fields_rows(@issue) %>" 15 | ) 16 | end 17 | -------------------------------------------------------------------------------- /app/views/custom_fields_groups/_custom_fields_group.html.erb: -------------------------------------------------------------------------------- 1 | "> 2 | <%= link_to custom_fields_group.name, edit_custom_fields_group_path(custom_fields_group) %> 3 | 4 | <% custom_fields_group.custom_fields.sorted.each do |cf| %> 5 | <%= textilizable cf.name %> 6 | <% end %> 7 | 8 | 9 | <%= reorder_handle(custom_fields_group, url: custom_fields_group_path(custom_fields_group), param: 'custom_fields_group') %> 10 | <%= delete_link custom_fields_group_path(custom_fields_group) %> 11 | 12 | 13 | -------------------------------------------------------------------------------- /app/views/custom_fields_groups/_form.html.erb: -------------------------------------------------------------------------------- 1 | <%= error_messages_for 'custom_fields_group' %> 2 | 3 |
4 |

<%= f.text_field :name, required: true, size: 25 %>

5 |

<%= group_fields_edit_tag @custom_fields_group %> 6 |

7 | -------------------------------------------------------------------------------- /app/views/custom_fields_groups/edit.html.erb: -------------------------------------------------------------------------------- 1 | <%= title [l(:label_custom_fields_group_plural), custom_fields_groups_path], @custom_fields_group.name %> 2 | 3 | <%= labelled_form_for :custom_fields_group, @custom_fields_group, url: custom_fields_group_path(@custom_fields_group), method: :patch do |f| %> 4 | <%= render partial: 'form', locals: { f: f } %> 5 |

6 | <%= submit_tag l :button_save %> 7 |

8 | <% end %> 9 | -------------------------------------------------------------------------------- /app/views/custom_fields_groups/index.html.erb: -------------------------------------------------------------------------------- 1 |
2 | <%= link_to l(:label_custom_fields_group_new), new_custom_fields_group_path, :class => 'icon icon-add' %> 3 |
4 | 5 | <%= title l :label_custom_fields_group_plural %> 6 | 7 | <% if @custom_fields_groups.any? %> 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | <%= render collection: @custom_fields_groups, partial: 'custom_fields_group' %> 18 | 19 |
<%= l(:field_name) %><%= l(:label_custom_field_plural) %>
20 | 21 | <% else %> 22 |

<%= l :label_no_data %>

23 | <% end %> 24 | 25 | <%= javascript_tag do %> 26 | $(function() { $("table.custom_fields_groups tbody").positionedItems(); }); 27 | <% end %> 28 | -------------------------------------------------------------------------------- /app/views/custom_fields_groups/new.html.erb: -------------------------------------------------------------------------------- 1 | <%= title [l(:label_custom_fields_group_plural), custom_fields_groups_path], l(:label_custom_fields_group_new) %> 2 | 3 | <%= labelled_form_for :custom_fields_group, @custom_fields_group, url: custom_fields_groups_path do |f| %> 4 | <%= render partial: 'form', locals: { f: f } %> 5 |

6 | <%= submit_tag l :button_create %> 7 | <%= submit_tag l(:button_create_and_continue), name: 'continue' %> 8 |

9 | <% end %> 10 | -------------------------------------------------------------------------------- /app/views/issues/_form_custom_fields.html.erb: -------------------------------------------------------------------------------- 1 | <% custom_fields_group_tag = User.current.pref.custom_fields_group_tag %> 2 | <% if custom_fields_group_tag.blank? %> 3 | <% custom_fields_group_tag = Setting.plugin_redmine_custom_fields_groups['custom_fields_group_tag'] || 'h4' %> 4 | <% end %> 5 | <% fieldset_default_state = User.current.pref.fieldset_default_state %> 6 | <% if fieldset_default_state.blank? %> 7 | <% fieldset_default_state = Setting.plugin_redmine_custom_fields_groups['fieldset_default_state'] || 'all_expended' %> 8 | <% end %> 9 | <% all_collapsed = (fieldset_default_state == 'all_collapsed') %> 10 | <% grouped_custom_field_values(@issue.editable_custom_field_values).each do |title, values| %> 11 | <% if values.present? %> 12 | <% full_width_values = values.select { |value| value.custom_field.full_width_layout? } %> 13 | <% half_width_values = values - full_width_values %> 14 | <% if custom_fields_group_tag == 'fieldset' %> 15 | <% if title.nil? %> 16 | <% if half_width_values.present? %> 17 |
18 |
19 | <% i = 0 %> 20 | <% split_on = (half_width_values.size / 2.0).ceil - 1 %> 21 | <% half_width_values.each do |value| %> 22 |

<%= custom_field_tag_with_label :issue, value, :required => @issue.required_attribute?(value.custom_field_id) %>

23 | <% if i == split_on -%> 24 |
25 |
26 | <% end -%> 27 | <% i += 1 -%> 28 | <% end -%> 29 |
30 |
31 | <% end %> 32 | <% full_width_values.each do |value| %> 33 |

<%= custom_field_tag_with_label :issue, value, :required => @issue.required_attribute?(value.custom_field_id) %>

34 | <%= wikitoolbar_for "issue_custom_field_values_#{value.custom_field_id}", preview_issue_path(:project_id => @issue.project, :issue_id => @issue.id) if value.custom_field.full_text_formatting? %> 35 | <% end %> 36 | <% else %> 37 | <% fieldset_class = 'collapsible custom-fields-groups' + (all_collapsed ? ' collapsed' : '') %> 38 | <% legend_class = 'icon icon-' + (all_collapsed ? 'collapsed' : ((Redmine::VERSION.to_s >= '5.0.0') ? 'expanded' : 'expended')) %> 39 | <% div_style = all_collapsed ? 'display: none' : '' %> 40 |
41 | <%= content_tag('legend', title, :onclick => "toggleFieldset(this);", :class => legend_class) %> 42 | <% if half_width_values.present? %> 43 |
44 |
45 | <% i = 0 %> 46 | <% split_on = (half_width_values.size / 2.0).ceil - 1 %> 47 | <% half_width_values.each do |value| %> 48 |

<%= custom_field_tag_with_label :issue, value, :required => @issue.required_attribute?(value.custom_field_id) %>

49 | <% if i == split_on -%> 50 |
51 |
52 | <% end -%> 53 | <% i += 1 -%> 54 | <% end -%> 55 |
56 |
57 | <% end %> 58 | <% full_width_values.each do |value| %> 59 |

<%= custom_field_tag_with_label :issue, value, :required => @issue.required_attribute?(value.custom_field_id) %>

60 | <%= wikitoolbar_for "issue_custom_field_values_#{value.custom_field_id}", preview_issue_path(:project_id => @issue.project, :issue_id => @issue.id) if value.custom_field.full_text_formatting? %> 61 | <% end %> 62 |
63 | <% end %> 64 | <% else %> 65 | <%= content_tag(custom_fields_group_tag, title, :class => "custom-fields-groups") unless title.nil? %> 66 | <% if half_width_values.present? %> 67 |
68 |
69 | <% i = 0 %> 70 | <% split_on = (half_width_values.size / 2.0).ceil - 1 %> 71 | <% half_width_values.each do |value| %> 72 |

<%= custom_field_tag_with_label :issue, value, :required => @issue.required_attribute?(value.custom_field_id) %>

73 | <% if i == split_on -%> 74 |
75 |
76 | <% end -%> 77 | <% i += 1 -%> 78 | <% end -%> 79 |
80 |
81 | <% end %> 82 | <% full_width_values.each do |value| %> 83 |

<%= custom_field_tag_with_label :issue, value, :required => @issue.required_attribute?(value.custom_field_id) %>

84 | <%= wikitoolbar_for "issue_custom_field_values_#{value.custom_field_id}", preview_issue_path(:project_id => @issue.project, :issue_id => @issue.id) if value.custom_field.full_text_formatting? %> 85 | <% end %> 86 | <% end %> 87 | <% end %> 88 | <% end %> 89 | -------------------------------------------------------------------------------- /app/views/settings/_redmine_custom_fields_groups.html.erb: -------------------------------------------------------------------------------- 1 |
2 |

<%= l(:label_custom_fields_group_settings) %>

3 |

4 | <%= content_tag(:label, l(:label_custom_fields_group_tag)) %> 5 | <%= select_tag('settings[custom_fields_group_tag]', 6 | options_for_select( 7 | RedmineCustomFieldsGroups::Options::group_tags, 8 | @settings['custom_fields_group_tag'].to_s)) %> 9 |

10 |

11 | <%= content_tag(:label, l(:label_fieldset_default_state)) %> 12 | <%= select_tag('settings[fieldset_default_state]', 13 | options_for_select( 14 | RedmineCustomFieldsGroups::Options::fieldset_states, 15 | @settings['fieldset_default_state'].to_s)) %> 16 |

17 |
18 | -------------------------------------------------------------------------------- /assets/images/textfields_group.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtt-project/redmine_custom_fields_groups/ca0df60ef85d12b56e7402d34da9ffb2695d28b2/assets/images/textfields_group.png -------------------------------------------------------------------------------- /assets/images/textfields_group.xcf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtt-project/redmine_custom_fields_groups/ca0df60ef85d12b56e7402d34da9ffb2695d28b2/assets/images/textfields_group.xcf -------------------------------------------------------------------------------- /assets/javascripts/custom_fields_groups.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gtt-project/redmine_custom_fields_groups/ca0df60ef85d12b56e7402d34da9ffb2695d28b2/assets/javascripts/custom_fields_groups.js -------------------------------------------------------------------------------- /assets/stylesheets/custom_fields_groups.css: -------------------------------------------------------------------------------- 1 | #admin-menu a.custom-fields-groups { background-image: url(../images/textfields_group.png);} 2 | 3 | h3.custom-fields-groups { 4 | background: #0001; 5 | border-bottom: 3px solid black; 6 | padding: 0.4em; 7 | } 8 | 9 | h4.custom-fields-groups { 10 | background: #0001; 11 | padding: 0.3em; 12 | } 13 | 14 | fieldset.collapsible.custom-fields-groups { 15 | border-width: 1px; 16 | margin-top: 5px; 17 | } 18 | 19 | fieldset.collapsible.custom-fields-groups>legend { 20 | font-size: 15px; 21 | font-weight: bold; 22 | } 23 | -------------------------------------------------------------------------------- /config/locales/de.yml: -------------------------------------------------------------------------------- 1 | # German strings go here for Rails i18n 2 | de: 3 | error_can_not_delete_custom_fields_group: Die Gruppe der benutzerdefinierten Felder 4 | kann nicht gelöscht werden 5 | label_custom_fields_group: Gruppe benutzerdefinierter Felder 6 | label_custom_fields_group_new: Neue Gruppe benutzerdefinierter Felder 7 | label_custom_fields_group_plural: Gruppen für benutzerdefinierte Felder 8 | label_custom_fields_group_settings: Einstellungen für Gruppen mit benutzerdefinierten 9 | Feldern 10 | label_custom_fields_group_tag: Tag für Gruppen von benutzerdefinierten Feldern 11 | label_group_tag_h3: H3 12 | label_group_tag_h4: H4 13 | label_group_tag_fieldset: Eingabefeld 14 | label_fieldset_default_state: Grundeinstellung für Eingabefeld 15 | label_fieldset_state_all_collapsed: Alle zusammengeklappt 16 | label_fieldset_state_all_expended: Alle erweitert 17 | -------------------------------------------------------------------------------- /config/locales/en.yml: -------------------------------------------------------------------------------- 1 | # English strings go here for Rails i18n 2 | en: 3 | label_custom_fields_group: Custom Fields Group 4 | label_custom_fields_group_new: New Custom Fields Group 5 | label_custom_fields_group_plural: Custom Fields Groups 6 | label_custom_fields_group_settings: Custom Fields Group Settings 7 | label_custom_fields_group_tag: Custom Fields Group Tag 8 | label_group_tag_h3: H3 9 | label_group_tag_h4: H4 10 | label_group_tag_fieldset: Fieldset 11 | label_fieldset_default_state: Fieldset Default State 12 | label_fieldset_state_all_expended: All expended 13 | label_fieldset_state_all_collapsed: All collapsed 14 | error_can_not_delete_custom_fields_group: Unable to delete custom fields group 15 | -------------------------------------------------------------------------------- /config/locales/ja.yml: -------------------------------------------------------------------------------- 1 | # Japanese strings go here for Rails i18n 2 | ja: 3 | label_custom_fields_group: カスタムフィールドグループ 4 | label_custom_fields_group_new: 新しいカスタムフィールドグループ 5 | label_custom_fields_group_plural: カスタムフィールドグループ 6 | label_custom_fields_group_settings: カスタムフィールドグループ設定 7 | label_custom_fields_group_tag: カスタムフィールドグループタグ 8 | label_group_tag_h3: H3 9 | label_group_tag_h4: H4 10 | label_group_tag_fieldset: フィールドセット 11 | label_fieldset_default_state: フィールドセットのデフォルト状態 12 | label_fieldset_state_all_expended: 全て展開 13 | label_fieldset_state_all_collapsed: 全て折りたたみ 14 | error_can_not_delete_custom_fields_group: カスタムフィールドグループを削除できません。 15 | -------------------------------------------------------------------------------- /config/routes.rb: -------------------------------------------------------------------------------- 1 | # Plugin's routes 2 | # See: http://guides.rubyonrails.org/routing.html 3 | 4 | resources :custom_fields_groups, except: %i[show] 5 | -------------------------------------------------------------------------------- /db/migrate/20211011081234_create_custom_fields_groups.rb: -------------------------------------------------------------------------------- 1 | class CreateCustomFieldsGroups < ActiveRecord::Migration[5.2] 2 | def change 3 | create_table :custom_fields_groups do |t| 4 | t.string :name, index: { unique: true } 5 | t.integer :position, default: nil, null: true 6 | 7 | t.timestamps null: false 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /db/migrate/20211011081244_create_custom_fields_group_fields.rb: -------------------------------------------------------------------------------- 1 | class CreateCustomFieldsGroupFields < ActiveRecord::Migration[5.2] 2 | def change 3 | create_table :custom_fields_group_fields, id: false do |t| 4 | t.references :custom_fields_group, index: true, foreign_key: true 5 | t.references :custom_field, index: { unique: true }, foreign_key: true, type: :integer 6 | 7 | # t.timestamps null: false 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /db/migrate/20240409124454_add_on_delete_cascade_to_foreign_key_custom_field.rb: -------------------------------------------------------------------------------- 1 | class AddOnDeleteCascadeToForeignKeyCustomField < ActiveRecord::Migration[5.2] 2 | def change 3 | remove_foreign_key :custom_fields_group_fields, :custom_fields 4 | add_foreign_key :custom_fields_group_fields, :custom_fields, on_delete: :cascade 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /init.rb: -------------------------------------------------------------------------------- 1 | require_relative 'lib/redmine_custom_fields_groups/hooks/view_layouts_base_html_head_hook' 2 | require_relative 'lib/redmine_custom_fields_groups/hooks/view_user_preferences_hook' 3 | 4 | Redmine::Plugin.register :redmine_custom_fields_groups do 5 | name 'Redmine Custom Fields Groups plugin' 6 | author 'Georepublic' 7 | author_url 'https://github.com/georepublic' 8 | url 'https://github.com/gtt-project/redmine_custom_fields_groups' 9 | description 'This is a plugin for grouping custom fields' 10 | version '1.0.0' 11 | 12 | requires_redmine :version_or_higher => '4.1.0' 13 | 14 | settings partial: 'settings/redmine_custom_fields_groups', 15 | default: { 16 | 'custom_fields_group_tag' => 'h4', 17 | 'fieldset_default_state' => 'all_expended' 18 | } 19 | 20 | menu :admin_menu, 21 | :custom_fields_group, 22 | { controller: 'custom_fields_groups', action: 'index' }, 23 | caption: :label_custom_fields_group_plural, 24 | after: :custom_fields, 25 | html: { class: 'icon icon-custom-fields custom-fields-groups' } 26 | end 27 | 28 | if Rails.version > '6.0' && Rails.autoloaders.zeitwerk_enabled? 29 | require_relative 'app/overrides/issues' 30 | Rails.application.config.after_initialize do 31 | RedmineCustomFieldsGroups.setup 32 | end 33 | else 34 | require 'redmine_custom_fields_groups' 35 | Rails.application.paths["app/overrides"] ||= [] 36 | Rails.application.paths["app/overrides"] << File.expand_path("../app/overrides", __FILE__) 37 | 38 | Rails.configuration.to_prepare do 39 | RedmineCustomFieldsGroups.setup 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /lib/redmine_custom_fields_groups.rb: -------------------------------------------------------------------------------- 1 | module RedmineCustomFieldsGroups 2 | class << self 3 | def setup 4 | IssuesHelper.send(:include, RedmineCustomFieldsGroups::Patches::IssuesHelperPatch) 5 | UserPreference.send(:include, RedmineCustomFieldsGroups::Patches::UserPreferencePatch) 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/redmine_custom_fields_groups/hooks/view_layouts_base_html_head_hook.rb: -------------------------------------------------------------------------------- 1 | module RedmineCustomFieldsGroups 2 | module Hooks 3 | class ViewLayoutsBaseHtmlHeadHook < Redmine::Hook::ViewListener 4 | 5 | include ActionView::Context 6 | 7 | def view_layouts_base_html_head(context={}) 8 | tags = []; 9 | tags << stylesheet_link_tag('custom_fields_groups', :plugin => "redmine_custom_fields_groups", :media => "all") 10 | tags << javascript_include_tag('custom_fields_groups', :plugin => 'redmine_custom_fields_groups') 11 | return tags.join("\n") 12 | end 13 | 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /lib/redmine_custom_fields_groups/hooks/view_user_preferences_hook.rb: -------------------------------------------------------------------------------- 1 | module RedmineCustomFieldsGroups 2 | module Hooks 3 | class ViewUserPreferencesHook < Redmine::Hook::ViewListener 4 | def view_users_form_preferences(context={}) 5 | user_custom_fields_group_options(context) 6 | end 7 | 8 | def view_my_account_preferences(context={}) 9 | user_custom_fields_group_options(context) 10 | end 11 | 12 | def user_custom_fields_group_options(context) 13 | user = context[:user] 14 | f = context[:form] 15 | s = '' 16 | 17 | s << "

" 18 | s << label_tag("pref_custom_fields_group_tag", l(:label_custom_fields_group_tag)) 19 | s << select_tag( 20 | "pref[custom_fields_group_tag]", 21 | options_for_select([["",""]] + RedmineCustomFieldsGroups::Options::group_tags, user.pref.custom_fields_group_tag), 22 | :id => 'pref_custom_fields_group_tag', 23 | :blank => '' 24 | ) 25 | s << "

" 26 | s << "

" 27 | s << label_tag("pref_fieldset_default_state", l(:label_fieldset_default_state)) 28 | s << select_tag( 29 | "pref[fieldset_default_state]", 30 | options_for_select([["",""]] + RedmineCustomFieldsGroups::Options::fieldset_states, user.pref.fieldset_default_state), 31 | :id => 'pref_fieldset_default_state', 32 | :blank => '' 33 | ) 34 | s << "

" 35 | 36 | return s.html_safe 37 | end 38 | end 39 | end 40 | end 41 | -------------------------------------------------------------------------------- /lib/redmine_custom_fields_groups/options.rb: -------------------------------------------------------------------------------- 1 | module RedmineCustomFieldsGroups 2 | class Options 3 | include Redmine::I18n 4 | def self.group_tags 5 | [ 6 | [l(:label_group_tag_h3), "h3"], 7 | [l(:label_group_tag_h4), "h4"], 8 | [l(:label_group_tag_fieldset), "fieldset"] 9 | ] 10 | end 11 | def self.fieldset_states 12 | [ 13 | [l(:label_fieldset_state_all_expended), "all_expended"], 14 | [l(:label_fieldset_state_all_collapsed), "all_collapsed"], 15 | ] 16 | end 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /lib/redmine_custom_fields_groups/patches/issues_helper_patch.rb: -------------------------------------------------------------------------------- 1 | module RedmineCustomFieldsGroups 2 | module Patches 3 | module IssuesHelperPatch 4 | 5 | def self.included(base) 6 | base.extend(ClassMethods) 7 | base.send(:prepend, InstanceMethods) 8 | base.class_eval do 9 | 10 | # Referred: 11 | # - Patch #30919: Group Issues Custom Fields - (Form like Issues) - Redmine 12 | # - https://www.redmine.org/issues/30919 13 | def grouped_custom_field_values(custom_field_values) 14 | keys_grouped = CustomFieldsGroupField. 15 | joins(:custom_fields_group, :custom_field). 16 | order('custom_fields_groups.position', 'custom_fields.position'). 17 | pluck('custom_fields_groups.name', :custom_field_id).group_by(&:shift) 18 | custom_fields_grouped = { nil => (keys_grouped[nil].nil? ? [] : 19 | keys_grouped[nil].map{|n| custom_field_values.select{|x| x.custom_field[:id] == n[0]}}.flatten) | 20 | custom_field_values.select{|y| ! keys_grouped.values.flatten.include?(y.custom_field[:id])}} 21 | keys_grouped.reject{|k,v| k == nil}.each{|k,v| custom_fields_grouped[k] = 22 | v.map{|n| custom_field_values.select{|x| x.custom_field[:id] == n[0]}}.flatten} 23 | custom_fields_grouped 24 | end 25 | 26 | def render_custom_fields_rows_by_groups(issue) 27 | custom_field_values = issue.visible_custom_field_values 28 | return if custom_field_values.empty? 29 | 30 | custom_fields_group_tag = User.current.pref.custom_fields_group_tag 31 | if custom_fields_group_tag.blank? 32 | custom_fields_group_tag = Setting.plugin_redmine_custom_fields_groups['custom_fields_group_tag'] || 'h4' 33 | end 34 | fieldset_default_state = User.current.pref.fieldset_default_state 35 | if fieldset_default_state.blank? 36 | fieldset_default_state = Setting.plugin_redmine_custom_fields_groups['fieldset_default_state'] || 'all_expended' 37 | end 38 | 39 | s = ''.html_safe 40 | grouped_custom_field_values(custom_field_values).each do |title, values| 41 | if values.present? 42 | if custom_fields_group_tag == 'fieldset' 43 | if title.nil? 44 | s << render_half_width_custom_fields_rows_by_grouped_values(issue, values) 45 | s << render_full_width_custom_fields_rows_by_grouped_values(issue, values) 46 | else 47 | s << content_tag('fieldset', :class => 'collapsible custom-fields-groups') do 48 | concat content_tag('legend', title, :onclick => 'toggleFieldset(this);', 49 | :class => 'icon icon-' + ((Redmine::VERSION.to_s >= '5.0.0') ? 'expanded' : 'expended')) 50 | concat render_half_width_custom_fields_rows_by_grouped_values(issue, values) 51 | concat render_full_width_custom_fields_rows_by_grouped_values(issue, values) 52 | end 53 | end 54 | else 55 | s << content_tag(custom_fields_group_tag, title, :class => 'custom-fields-groups') unless title.nil? 56 | s << render_half_width_custom_fields_rows_by_grouped_values(issue, values) 57 | s << render_full_width_custom_fields_rows_by_grouped_values(issue, values) 58 | end 59 | end 60 | end 61 | # temporary hack 62 | if custom_fields_group_tag == 'fieldset' && fieldset_default_state == 'all_collapsed' 63 | s << javascript_tag("$('div.issue div.attributes fieldset.custom-fields-groups>legend').each(function(idx,elem){toggleFieldset(elem);})") 64 | end 65 | s 66 | end 67 | 68 | def render_half_width_custom_fields_rows_by_grouped_values(issue, custom_field_values) 69 | values = custom_field_values.reject {|value| value.custom_field.full_width_layout?} 70 | return if values.empty? 71 | 72 | half = (values.size / 2.0).ceil 73 | issue_fields_rows do |rows| 74 | values.each_with_index do |value, i| 75 | m = (i < half ? :left : :right) 76 | rows.send m, custom_field_name_tag(value.custom_field), custom_field_value_tag(value), :class => value.custom_field.css_classes 77 | end 78 | end 79 | end 80 | 81 | def render_full_width_custom_fields_rows_by_grouped_values(issue, custom_field_values) 82 | values = custom_field_values.select {|value| value.custom_field.full_width_layout?} 83 | return if values.empty? 84 | 85 | s = ''.html_safe 86 | values.each_with_index do |value, i| 87 | # attr_value_tag = custom_field_value_tag(value) 88 | # next if attr_value_tag.blank? 89 | 90 | # content = 91 | # content_tag('hr') + 92 | # content_tag('p', content_tag('strong', custom_field_name_tag(value.custom_field) )) + 93 | # content_tag('div', attr_value_tag, class: 'value') 94 | # s << content_tag('div', content, class: "#{value.custom_field.css_classes} attribute") 95 | content = content_tag('div', custom_field_name_tag(value.custom_field) + ":", :class => 'label') + 96 | content_tag('div', custom_field_value_tag(value), :class => 'value') 97 | content = content_tag('div', content, :class => "#{value.custom_field.css_classes} attribute") 98 | s << content_tag('div', content, :class => 'splitcontent') 99 | end 100 | s 101 | end 102 | end #base 103 | end #self 104 | 105 | module InstanceMethods 106 | 107 | end #module 108 | 109 | module ClassMethods 110 | 111 | end #module 112 | end #module 113 | end #module 114 | end #module 115 | -------------------------------------------------------------------------------- /lib/redmine_custom_fields_groups/patches/user_preference_patch.rb: -------------------------------------------------------------------------------- 1 | module RedmineCustomFieldsGroups 2 | module Patches 3 | module UserPreferencePatch 4 | 5 | def self.included(base) # :nodoc: 6 | base.send(:include, InstanceMethods) 7 | 8 | base.class_eval do 9 | safe_attributes 'custom_fields_group_tag', 'fieldset_default_state' 10 | end 11 | end 12 | 13 | module InstanceMethods 14 | def custom_fields_group_tag 15 | self[:custom_fields_group_tag] 16 | end 17 | 18 | def custom_fields_group_tag=(new_value) 19 | self[:custom_fields_group_tag] = new_value 20 | end 21 | 22 | def fieldset_default_state 23 | self[:fieldset_default_state] 24 | end 25 | 26 | def fieldset_default_state=(new_value) 27 | self[:fieldset_default_state] = new_value 28 | end 29 | end 30 | end 31 | end 32 | end 33 | -------------------------------------------------------------------------------- /test/fixtures/custom_fields_group_fields.yml: -------------------------------------------------------------------------------- 1 | custom_fields_group_fields_101: 2 | custom_fields_group_id: 1 3 | custom_field_id: 1 4 | custom_fields_group_fields_102: 5 | custom_fields_group_id: 1 6 | custom_field_id: 2 7 | custom_fields_group_fields_206: 8 | custom_fields_group_id: 2 9 | custom_field_id: 6 10 | custom_fields_group_fields_308: 11 | custom_fields_group_id: 3 12 | custom_field_id: 8 13 | -------------------------------------------------------------------------------- /test/fixtures/custom_fields_groups.yml: -------------------------------------------------------------------------------- 1 | custom_fields_groups_100: 2 | id: 1 3 | name: Group 1 4 | position: 1 5 | custom_fields_groups_200: 6 | id: 2 7 | name: Group 2 8 | position: 2 9 | custom_fields_groups_300: 10 | id: 3 11 | name: Group 3 12 | position: 3 13 | -------------------------------------------------------------------------------- /test/functional/custom_fields_groups_controller_test.rb: -------------------------------------------------------------------------------- 1 | require_relative '../test_helper' 2 | 3 | class CustomFieldsGroupsControllerTest < ActionController::TestCase 4 | fixtures :custom_fields, :custom_fields_groups, :custom_fields_group_fields, 5 | :users 6 | 7 | setup do 8 | User.current = nil 9 | @request.session[:user_id] = 1 # admin 10 | end 11 | 12 | teardown do 13 | @request.session.clear 14 | end 15 | 16 | test 'should require admin' do 17 | @request.session[:user_id] = nil 18 | get :index 19 | assert_redirected_to '/login?back_url=http%3A%2F%2Ftest.host%2Fcustom_fields_groups' 20 | end 21 | 22 | test 'should get index' do 23 | get :index 24 | assert_response :success 25 | 26 | assert_select 'table.custom_fields_groups tbody' do 27 | assert_select 'tr', CustomFieldsGroup.count 28 | assert_select 'a[href="/custom_fields_groups/1/edit"]', :text => 'Group 1' 29 | end 30 | end 31 | 32 | test 'should get new' do 33 | get :new 34 | assert_response :success 35 | assert_select 'input[type=text][name=?]', 'custom_fields_group[name]' 36 | assert_select 'input[type=checkbox][name=?][value=?]', 'custom_fields_group[custom_field_ids][]', '9' 37 | end 38 | 39 | test 'should create custom fields gruop' do 40 | assert_difference 'CustomFieldsGroup.count' do 41 | post :create, :params => { 42 | :custom_fields_group => { 43 | :name => 'Group 4', 44 | :custom_field_ids => [9] 45 | } 46 | } 47 | end 48 | assert_redirected_to '/custom_fields_groups' 49 | 50 | assert custom_fields_group = CustomFieldsGroup.find_by_name('Group 4') 51 | assert_equal [9], custom_fields_group.custom_field_ids 52 | assert_equal 4, custom_fields_group.position 53 | end 54 | 55 | test 'should not create custom fields gruop without name' do 56 | post :create, :params => { 57 | :custom_fields_group => { 58 | :name => '', 59 | :custom_field_ids => [9] 60 | } 61 | } 62 | assert_response :success 63 | assert_select_error /Name cannot be blank/ 64 | end 65 | 66 | test 'should get edit' do 67 | get :edit, :params => { :id => 1 } 68 | assert_response :success 69 | 70 | assert_select 'input[type=text][name=?][value=?]', 'custom_fields_group[name]', 'Group 1' 71 | assert_select 'input[type=checkbox][name=?][value=?][checked=?]', 'custom_fields_group[custom_field_ids][]', '1', 'checked' 72 | assert_select 'input[type=checkbox][name=?][value=?][checked=?]', 'custom_fields_group[custom_field_ids][]', '2', 'checked' 73 | end 74 | 75 | test 'should update custom fields group' do 76 | post :update, :params => { 77 | :id => 1, 78 | :custom_fields_group => { 79 | :name => 'Group 1 updated', 80 | :custom_field_ids => [2] 81 | } 82 | } 83 | assert_redirected_to '/custom_fields_groups' 84 | 85 | assert custom_fields_group = CustomFieldsGroup.find(1) 86 | assert_equal 'Group 1 updated', custom_fields_group.name 87 | assert_equal [2], custom_fields_group.custom_field_ids 88 | end 89 | 90 | test 'should not update custom fields group without name' do 91 | post :update, :params => { 92 | :id => 1, 93 | :custom_fields_group => { 94 | :name => '', 95 | :custom_field_ids => [2] 96 | } 97 | } 98 | assert_response :success 99 | assert_select_error /Name cannot be blank/ 100 | end 101 | 102 | test 'should destroy custom fields group' do 103 | assert_difference 'CustomFieldsGroup.count', -1 do 104 | delete :destroy, :params => { :id => 1 } 105 | end 106 | assert_redirected_to '/custom_fields_groups' 107 | end 108 | 109 | test 'move highest' do 110 | put :update, :params => { 111 | :id => 2, 112 | :custom_fields_group => { 113 | :position => 1 114 | } 115 | }, :xhr => true 116 | assert_response :success 117 | assert_equal 1, CustomFieldsGroup.find(2).position 118 | end 119 | 120 | test 'move higher' do 121 | position = CustomFieldsGroup.find(2).position 122 | put :update, :params => { 123 | :id => 2, 124 | :custom_fields_group => { 125 | :position => position - 1 126 | } 127 | }, :xhr => true 128 | assert_response :success 129 | assert_equal position - 1, CustomFieldsGroup.find(2).position 130 | end 131 | 132 | test 'move lower' do 133 | position = CustomFieldsGroup.find(2).position 134 | put :update, :params => { 135 | :id => 2, 136 | :custom_fields_group => { 137 | :position => position + 1 138 | } 139 | }, :xhr => true 140 | assert_response :success 141 | assert_equal position + 1, CustomFieldsGroup.find(2).position 142 | end 143 | 144 | test 'move lowest' do 145 | put :update, :params => { 146 | :id => 2, 147 | :custom_fields_group => { 148 | :position => CustomFieldsGroup.count 149 | } 150 | }, :xhr => true 151 | assert_response :success 152 | assert_equal CustomFieldsGroup.count, CustomFieldsGroup.find(2).position 153 | end 154 | end 155 | -------------------------------------------------------------------------------- /test/integration/layout_test.rb: -------------------------------------------------------------------------------- 1 | require_relative '../test_helper' 2 | 3 | class LayoutTest < Redmine::IntegrationTest 4 | fixtures :projects, :users, :email_addresses, :roles, :members, :member_roles, 5 | :trackers, :projects_trackers, :enabled_modules, :issue_statuses, :issues, 6 | :enumerations, :custom_fields, :custom_values, :custom_fields_trackers, 7 | :watchers, :journals, :journal_details, :versions, 8 | :workflows, :wikis, :wiki_pages, :wiki_contents, :wiki_content_versions, 9 | :custom_fields, :custom_fields_groups, :custom_fields_group_fields 10 | 11 | setup do 12 | User.current = nil 13 | @user = User.find_by_login('dlopper') 14 | end 15 | 16 | teardown do 17 | Setting.where(name: 'plugin_redmine_custom_fields_groups').destroy_all 18 | Setting.clear_cache 19 | @user.pref.others.delete(:custom_fields_group_tag) 20 | @user.pref.others.delete(:fieldset_default_state) 21 | end 22 | 23 | test 'should show custom fields groups with default h4 tag in issue' do 24 | log_user('dlopper', 'foo') 25 | get '/issues/1' 26 | assert_response :success 27 | 28 | # issue details 29 | assert_select 'div.issue.details div.attributes h4.custom-fields-groups:contains("Group 1") + div.splitcontent' do 30 | assert_select 'div.splitcontentleft:nth-of-type(1)' do 31 | assert_select 'span', :text => 'Searchable field' 32 | assert_select 'div.value', :text => '125' 33 | end 34 | assert_select 'div.splitcontentleft:nth-of-type(2)' do 35 | assert_select 'span', :text => 'Database' 36 | assert_select 'div.value', :text => '' 37 | end 38 | end 39 | assert_select 'div.issue.details div.attributes h4.custom-fields-groups:contains("Group 2") + div.splitcontent' do 40 | assert_select 'div.splitcontentleft:nth-of-type(1)' do 41 | assert_select 'span', :text => 'Float field' 42 | assert_select 'div.value', :text => '2.10' 43 | end 44 | end 45 | assert_select 'div.issue.details div.attributes h4.custom-fields-groups:contains("Group 3") + div.splitcontent' do 46 | assert_select 'div.splitcontentleft:nth-of-type(1)' do 47 | assert_select 'span', :text => 'Custom date' 48 | assert_select 'div.value', :text => '12/01/2009' 49 | end 50 | end 51 | 52 | # issue edit 53 | assert_select 'div#update div.attributes h4.custom-fields-groups:contains("Group 1") + div.splitcontent' do 54 | assert_select 'div.splitcontentleft:nth-of-type(1)' do 55 | assert_select 'span', :text => 'Searchable field' 56 | assert_select 'input[type=text][name=?]', 'issue[custom_field_values][2]', :value => '125' 57 | end 58 | assert_select 'div.splitcontentright:nth-of-type(1)' do 59 | assert_select 'span', :text => 'Database' 60 | assert_select 'select[name=?]', 'issue[custom_field_values][1]', :value => '' 61 | end 62 | end 63 | assert_select 'div#update div.attributes h4.custom-fields-groups:contains("Group 2") + div.splitcontent' do 64 | assert_select 'div.splitcontentleft:nth-of-type(1)' do 65 | assert_select 'span', :text => 'Float field' 66 | assert_select 'input[type=text][name=?]', 'issue[custom_field_values][6]', :value => '2.1' 67 | end 68 | end 69 | assert_select 'div#update div.attributes h4.custom-fields-groups:contains("Group 3") + div.splitcontent' do 70 | assert_select 'div.splitcontentleft:nth-of-type(1)' do 71 | assert_select 'span', :text => 'Custom date' 72 | assert_select 'input[type=date][name=?]', 'issue[custom_field_values][8]', :value => '2009-12-01' 73 | end 74 | end 75 | end 76 | 77 | test 'should show custom fields groups with h3 tag in issue from plugin setting' do 78 | Setting.plugin_redmine_custom_fields_groups = { 'custom_fields_group_tag' => 'h3' } 79 | 80 | log_user('dlopper', 'foo') 81 | get '/issues/1' 82 | assert_response :success 83 | 84 | # issue details 85 | assert_select 'div.issue.details div.attributes h3.custom-fields-groups:contains("Group 1") + div.splitcontent' do 86 | assert_select 'div.splitcontentleft:nth-of-type(1)' do 87 | assert_select 'span', :text => 'Searchable field' 88 | assert_select 'div.value', :text => '125' 89 | end 90 | assert_select 'div.splitcontentleft:nth-of-type(2)' do 91 | assert_select 'span', :text => 'Database' 92 | assert_select 'div.value', :text => '' 93 | end 94 | end 95 | assert_select 'div.issue.details div.attributes h3.custom-fields-groups:contains("Group 2") + div.splitcontent' do 96 | assert_select 'div.splitcontentleft:nth-of-type(1)' do 97 | assert_select 'span', :text => 'Float field' 98 | assert_select 'div.value', :text => '2.10' 99 | end 100 | end 101 | assert_select 'div.issue.details div.attributes h3.custom-fields-groups:contains("Group 3") + div.splitcontent' do 102 | assert_select 'div.splitcontentleft:nth-of-type(1)' do 103 | assert_select 'span', :text => 'Custom date' 104 | assert_select 'div.value', :text => '12/01/2009' 105 | end 106 | end 107 | 108 | # issue edit 109 | assert_select 'div#update div.attributes h3.custom-fields-groups:contains("Group 1") + div.splitcontent' do 110 | assert_select 'div.splitcontentleft:nth-of-type(1)' do 111 | assert_select 'span', :text => 'Searchable field' 112 | assert_select 'input[type=text][name=?]', 'issue[custom_field_values][2]', :value => '125' 113 | end 114 | assert_select 'div.splitcontentright:nth-of-type(1)' do 115 | assert_select 'span', :text => 'Database' 116 | assert_select 'select[name=?]', 'issue[custom_field_values][1]', :value => '' 117 | end 118 | end 119 | assert_select 'div#update div.attributes h3.custom-fields-groups:contains("Group 2") + div.splitcontent' do 120 | assert_select 'div.splitcontentleft:nth-of-type(1)' do 121 | assert_select 'span', :text => 'Float field' 122 | assert_select 'input[type=text][name=?]', 'issue[custom_field_values][6]', :value => '2.1' 123 | end 124 | end 125 | assert_select 'div#update div.attributes h3.custom-fields-groups:contains("Group 3") + div.splitcontent' do 126 | assert_select 'div.splitcontentleft:nth-of-type(1)' do 127 | assert_select 'span', :text => 'Custom date' 128 | assert_select 'input[type=date][name=?]', 'issue[custom_field_values][8]', :value => '2009-12-01' 129 | end 130 | end 131 | end 132 | 133 | test 'should show custom fields groups with fieldset tag all expended in issue from plugin setting' do 134 | Setting.plugin_redmine_custom_fields_groups = { 135 | 'custom_fields_group_tag' => 'fieldset', 136 | 'fieldset_default_state' => 'all_expended' 137 | } 138 | 139 | log_user('dlopper', 'foo') 140 | get '/issues/1' 141 | assert_response :success 142 | 143 | # issue details 144 | assert_select 'div.issue.details div.attributes fieldset.custom-fields-groups > legend.icon:contains("Group 1") + div.splitcontent' do 145 | assert_select 'div.splitcontentleft:nth-of-type(1)' do 146 | assert_select 'span', :text => 'Searchable field' 147 | assert_select 'div.value', :text => '125' 148 | end 149 | assert_select 'div.splitcontentleft:nth-of-type(2)' do 150 | assert_select 'span', :text => 'Database' 151 | assert_select 'div.value', :text => '' 152 | end 153 | end 154 | assert_select 'div.issue.details div.attributes fieldset.custom-fields-groups > legend.icon:contains("Group 2") + div.splitcontent' do 155 | assert_select 'div.splitcontentleft:nth-of-type(1)' do 156 | assert_select 'span', :text => 'Float field' 157 | assert_select 'div.value', :text => '2.10' 158 | end 159 | end 160 | assert_select 'div.issue.details div.attributes fieldset.custom-fields-groups > legend.icon:contains("Group 3") + div.splitcontent' do 161 | assert_select 'div.splitcontentleft:nth-of-type(1)' do 162 | assert_select 'span', :text => 'Custom date' 163 | assert_select 'div.value', :text => '12/01/2009' 164 | end 165 | end 166 | 167 | # issue edit 168 | assert_select 'div#update div.attributes fieldset.custom-fields-groups > legend.icon:contains("Group 1") + div.splitcontent' do 169 | assert_select 'div.splitcontentleft:nth-of-type(1)' do 170 | assert_select 'span', :text => 'Searchable field' 171 | assert_select 'input[type=text][name=?]', 'issue[custom_field_values][2]', :value => '125' 172 | end 173 | assert_select 'div.splitcontentright:nth-of-type(1)' do 174 | assert_select 'span', :text => 'Database' 175 | assert_select 'select[name=?]', 'issue[custom_field_values][1]', :value => '' 176 | end 177 | end 178 | assert_select 'div#update div.attributes fieldset.custom-fields-groups > legend.icon:contains("Group 2") + div.splitcontent' do 179 | assert_select 'div.splitcontentleft:nth-of-type(1)' do 180 | assert_select 'span', :text => 'Float field' 181 | assert_select 'input[type=text][name=?]', 'issue[custom_field_values][6]', :value => '2.1' 182 | end 183 | end 184 | assert_select 'div#update div.attributes fieldset.custom-fields-groups > legend.icon:contains("Group 3") + div.splitcontent' do 185 | assert_select 'div.splitcontentleft:nth-of-type(1)' do 186 | assert_select 'span', :text => 'Custom date' 187 | assert_select 'input[type=date][name=?]', 'issue[custom_field_values][8]', :value => '2009-12-01' 188 | end 189 | end 190 | end 191 | 192 | test 'should override user preference setting than plugin setting' do 193 | Setting.plugin_redmine_custom_fields_groups = { 194 | 'custom_fields_group_tag' => 'h4', # default 195 | 'fieldset_default_state' => 'all_collapsed' 196 | } 197 | 198 | @user.pref.others[:custom_fields_group_tag] = 'fieldset' 199 | @user.pref.others[:fieldset_default_state] = 'all_expended' 200 | @user.pref.save! 201 | 202 | log_user('dlopper', 'foo') 203 | get '/issues/1' 204 | assert_response :success 205 | 206 | # issue details 207 | assert_select 'div.issue.details div.attributes fieldset.custom-fields-groups > legend.icon:contains("Group 1") + div.splitcontent' do 208 | assert_select 'div.splitcontentleft:nth-of-type(1)' do 209 | assert_select 'span', :text => 'Searchable field' 210 | assert_select 'div.value', :text => '125' 211 | end 212 | assert_select 'div.splitcontentleft:nth-of-type(2)' do 213 | assert_select 'span', :text => 'Database' 214 | assert_select 'div.value', :text => '' 215 | end 216 | end 217 | assert_select 'div.issue.details div.attributes fieldset.custom-fields-groups > legend.icon:contains("Group 2") + div.splitcontent' do 218 | assert_select 'div.splitcontentleft:nth-of-type(1)' do 219 | assert_select 'span', :text => 'Float field' 220 | assert_select 'div.value', :text => '2.10' 221 | end 222 | end 223 | assert_select 'div.issue.details div.attributes fieldset.custom-fields-groups > legend.icon:contains("Group 3") + div.splitcontent' do 224 | assert_select 'div.splitcontentleft:nth-of-type(1)' do 225 | assert_select 'span', :text => 'Custom date' 226 | assert_select 'div.value', :text => '12/01/2009' 227 | end 228 | end 229 | 230 | # issue edit 231 | assert_select 'div#update div.attributes fieldset.custom-fields-groups > legend.icon:contains("Group 1") + div.splitcontent' do 232 | assert_select 'div.splitcontentleft:nth-of-type(1)' do 233 | assert_select 'span', :text => 'Searchable field' 234 | assert_select 'input[type=text][name=?]', 'issue[custom_field_values][2]', :value => '125' 235 | end 236 | assert_select 'div.splitcontentright:nth-of-type(1)' do 237 | assert_select 'span', :text => 'Database' 238 | assert_select 'select[name=?]', 'issue[custom_field_values][1]', :value => '' 239 | end 240 | end 241 | assert_select 'div#update div.attributes fieldset.custom-fields-groups > legend.icon:contains("Group 2") + div.splitcontent' do 242 | assert_select 'div.splitcontentleft:nth-of-type(1)' do 243 | assert_select 'span', :text => 'Float field' 244 | assert_select 'input[type=text][name=?]', 'issue[custom_field_values][6]', :value => '2.1' 245 | end 246 | end 247 | assert_select 'div#update div.attributes fieldset.custom-fields-groups > legend.icon:contains("Group 3") + div.splitcontent' do 248 | assert_select 'div.splitcontentleft:nth-of-type(1)' do 249 | assert_select 'span', :text => 'Custom date' 250 | assert_select 'input[type=date][name=?]', 'issue[custom_field_values][8]', :value => '2009-12-01' 251 | end 252 | end 253 | end 254 | end 255 | -------------------------------------------------------------------------------- /test/system/fieldset_test.rb: -------------------------------------------------------------------------------- 1 | require_relative '../../../../test/application_system_test_case' 2 | require_relative '../test_helper' 3 | 4 | class FieldsetTest < ApplicationSystemTestCase 5 | fixtures :projects, :users, :email_addresses, :roles, :members, :member_roles, 6 | :trackers, :projects_trackers, :enabled_modules, :issue_statuses, :issues, 7 | :enumerations, :custom_fields, :custom_values, :custom_fields_trackers, 8 | :watchers, :journals, :journal_details, 9 | :custom_fields, :custom_fields_groups, :custom_fields_group_fields 10 | 11 | teardown do 12 | Setting.where(name: 'plugin_redmine_custom_fields_groups').destroy_all 13 | Setting.clear_cache 14 | end 15 | 16 | test 'click group title should collapse/expand fieldset with default state all_expended' do 17 | Setting.plugin_redmine_custom_fields_groups = { 18 | 'custom_fields_group_tag' => 'fieldset', 19 | 'fieldset_default_state' => 'all_expended' 20 | } 21 | 22 | log_user('dlopper', 'foo') 23 | visit '/issues/1' 24 | 25 | # issue details 26 | within('div.issue.details div.attributes') do 27 | assert page.has_content?('Group 1') 28 | # default expanded 29 | assert page.has_content?('Searchable field') 30 | assert page.has_content?('Database') 31 | # click group title 32 | find('fieldset.custom-fields-groups > legend.icon', :text => 'Group 1').click 33 | # collapsed fields 34 | assert page.has_no_content?('Searchable field') 35 | assert page.has_no_content?('Database') 36 | # click group title, again 37 | find('fieldset.custom-fields-groups > legend.icon', :text => 'Group 1').click 38 | # expanded fields 39 | assert page.has_content?('Searchable field') 40 | assert page.has_content?('Database') 41 | end 42 | 43 | # issue edit 44 | page.first(:link, 'Edit').click 45 | page.find('#issue_notes:focus') 46 | sleep 0.1 47 | within('div#update div.attributes') do 48 | assert page.has_content?('Group 1') 49 | # default expanded 50 | assert page.has_content?('Searchable field') 51 | assert page.has_content?('Database') 52 | # click group title 53 | find('fieldset.custom-fields-groups > legend.icon', :text => 'Group 1').click 54 | # collapsed fields 55 | assert page.has_no_content?('Searchable field') 56 | assert page.has_no_content?('Database') 57 | # click group title, again 58 | find('fieldset.custom-fields-groups > legend.icon', :text => 'Group 1').click 59 | # expanded fields 60 | assert page.has_content?('Searchable field') 61 | assert page.has_content?('Database') 62 | end 63 | end 64 | 65 | test 'click group title should expand/collapse fieldset with default state all_collapsed' do 66 | Setting.plugin_redmine_custom_fields_groups = { 67 | 'custom_fields_group_tag' => 'fieldset', 68 | 'fieldset_default_state' => 'all_collapsed' 69 | } 70 | 71 | log_user('dlopper', 'foo') 72 | visit '/issues/1' 73 | 74 | # issue details 75 | within('div.issue.details div.attributes') do 76 | assert page.has_content?('Group 1') 77 | # default collapsed 78 | assert page.has_no_content?('Searchable field') 79 | assert page.has_no_content?('Database') 80 | # click group title 81 | find('fieldset.custom-fields-groups > legend.icon', :text => 'Group 1').click 82 | # expanded fields 83 | assert page.has_content?('Searchable field') 84 | assert page.has_content?('Database') 85 | # click group title, again 86 | find('fieldset.custom-fields-groups > legend.icon', :text => 'Group 1').click 87 | # collapsed fields 88 | assert page.has_no_content?('Searchable field') 89 | assert page.has_no_content?('Database') 90 | end 91 | 92 | # issue edit 93 | page.first(:link, 'Edit').click 94 | page.find('#issue_notes:focus') 95 | sleep 0.1 96 | within('div#update div.attributes') do 97 | assert page.has_content?('Group 1') 98 | # default collapsed 99 | assert page.has_no_content?('Searchable field') 100 | assert page.has_no_content?('Database') 101 | # click group title 102 | find('fieldset.custom-fields-groups > legend.icon', :text => 'Group 1').click 103 | # expanded fields 104 | assert page.has_content?('Searchable field') 105 | assert page.has_content?('Database') 106 | # click group title, again 107 | find('fieldset.custom-fields-groups > legend.icon', :text => 'Group 1').click 108 | # collapsed fields 109 | assert page.has_no_content?('Searchable field') 110 | assert page.has_no_content?('Database') 111 | end 112 | end 113 | end 114 | -------------------------------------------------------------------------------- /test/test_helper.rb: -------------------------------------------------------------------------------- 1 | # Load the Redmine helper 2 | require_relative '../../../test/test_helper' 3 | 4 | ActiveRecord::FixtureSet.create_fixtures( 5 | File.dirname(__FILE__) + '/fixtures', 6 | ['custom_fields_groups', 'custom_fields_group_fields'] 7 | ) 8 | -------------------------------------------------------------------------------- /test/unit/custom_fields_group_field_test.rb: -------------------------------------------------------------------------------- 1 | require_relative '../test_helper' 2 | 3 | class CustomFieldsGroupFieldTest < ActiveSupport::TestCase 4 | 5 | # Replace this with your real tests. 6 | def test_truth 7 | assert true 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /test/unit/custom_fields_group_test.rb: -------------------------------------------------------------------------------- 1 | require_relative '../test_helper' 2 | 3 | class CustomFieldsGroupTest < ActiveSupport::TestCase 4 | fixtures :custom_fields, :custom_fields_groups, :custom_fields_group_fields 5 | 6 | test 'create' do 7 | issue_custom_field = IssueCustomField.new(:name => 'test', :field_format => 'text') 8 | issue_custom_field.save! 9 | issue_custom_field.reload 10 | 11 | custom_fields_group = CustomFieldsGroup.new 12 | custom_fields_group.name = 'test' 13 | custom_fields_group.custom_field_ids = [issue_custom_field.id] 14 | assert custom_fields_group.save 15 | custom_fields_group.reload 16 | assert_equal [issue_custom_field.id], custom_fields_group.custom_field_ids 17 | assert_equal CustomFieldsGroup.count, custom_fields_group.position 18 | end 19 | 20 | test 'should require name' do 21 | custom_fields_group = CustomFieldsGroup.new 22 | assert_not custom_fields_group.save 23 | assert custom_fields_group.errors[:name] 24 | end 25 | 26 | test 'should validate name uniqueness' do 27 | assert_difference 'CustomFieldsGroup.count' do 28 | custom_fields_group = CustomFieldsGroup.new 29 | custom_fields_group.name = 'test' 30 | assert custom_fields_group.save 31 | assert_equal 'test', custom_fields_group.name 32 | end 33 | 34 | assert_no_difference 'CustomFieldsGroup.count' do 35 | custom_fields_group = CustomFieldsGroup.new 36 | custom_fields_group.name = 'test' 37 | assert_not custom_fields_group.save 38 | assert custom_fields_group.errors[:name] 39 | end 40 | end 41 | 42 | test 'deletion of custom_field_group should delete custom_fields_group_field' do 43 | custom_fields_group = custom_fields_groups(:custom_fields_groups_100) 44 | assert_difference 'CustomFieldsGroupField.count', -2 do 45 | assert custom_fields_group.destroy 46 | end 47 | end 48 | 49 | test 'deletion of custom_field should delete custom_fields_group_field' do 50 | custom_field = custom_fields(:custom_fields_001) 51 | assert_difference 'CustomFieldsGroup.find(1).custom_fields.count', -1 do 52 | assert custom_field.destroy 53 | end 54 | end 55 | end 56 | --------------------------------------------------------------------------------