• Stan Hu's avatar
    Fix inability to set visibility_level on project via API · dcba5279
    Stan Hu authored
    Consider the scenario:
    
    1. The default visibility level is set to internal
    2. A user attempts to create a private project within a private group
    
    Previously this would always fail because default_value_for would
    overwrite the private visibility setting, no matter what
    visibility_level were specified. This was happening because
    default_value_for was confused by the default value of 0 specified by
    the database schema.
    
    default_value_for attempts to assign the default value in the block by
    checking whether the attribute has changed. The problem is that since
    the default value by the database was 0, and the user requested 0, this
    appeared as though no changes were made. As a result, default_value_for
    would always overwrite the user's preference.
    
    To fix this, we remove the use of default_value_for and only set the
    visibility level to the default application setting when no preference
    has been given at creation time.
    
    Closes #63158
    dcba5279
visibility_level.rb 3.8 KB