File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -444,6 +444,8 @@ def error_labels
444444 end
445445
446446 def access_limited_named_users = ( users )
447+ return unless Flipflop . enabled? ( :access_limited_named_users )
448+
447449 user_emails = users . split ( "," ) . map ( &:strip ) . reject ( &:empty? )
448450
449451 user_emails . each do |email |
Original file line number Diff line number Diff line change 1616 bold : true ,
1717 checked : edition . organisations? ,
1818 } ,
19- {
20- value : :named_users ,
21- text : "Limit access to named publishers" ,
22- bold : true ,
23- checked : edition . named_users? ,
24- conditional : ( render "govuk_publishing_components/components/textarea" , {
25- label : {
26- text : "Add publishers who will have access" ,
27- bold : true ,
28- } ,
29- name : "edition[access_limited_named_users]" ,
30- textarea_id : "edition_access_limited_named_users" ,
31- error_message : nil ,
32- value : nil ,
33- hint : "Add the emails of the publishers who will have access to this document before publishing. After publishing the document will be available to all publishers in the organisation associated with this document"
34- } ) ,
35- } ,
36- ] ,
19+ (
20+ Flipflop . enabled? ( :access_limited_named_users ) ?
21+ {
22+ value : :named_users ,
23+ text : "Limit access to named publishers" ,
24+ bold : true ,
25+ checked : edition . named_users? ,
26+ conditional : render ( "govuk_publishing_components/components/textarea" , {
27+ label : {
28+ text : "Add publishers who will have access" ,
29+ bold : true ,
30+ } ,
31+ name : "edition[access_limited_named_users]" ,
32+ textarea_id : "edition_access_limited_named_users" ,
33+ error_message : nil ,
34+ value : nil ,
35+ hint : "Add the emails of the publishers who will have access to this document before publishing. After publishing the document will be available to all publishers in the organisation associated with this document" ,
36+ } )
37+ }
38+ : nil
39+ ) ,
40+ ] . compact ,
3741 } %>
3842</ div >
Original file line number Diff line number Diff line change 3333 feature :configurable_document_types ,
3434 description : "Enable 'in development' config-driven document types (alongside the 'live' ones)" ,
3535 default : Rails . env . development?
36+ feature :access_limited_named_users ,
37+ description : "Allow documents to be access-limited to specific named editors by email" ,
38+ default : false
3639end
Original file line number Diff line number Diff line change @@ -1007,6 +1007,26 @@ class EditionTest < ActiveSupport::TestCase
10071007 assert_not edition . valid?
10081008 end
10091009
1010+ test "access_limited_named_users= creates EditionUserAccess records when feature is enabled" do
1011+ edition = create ( :edition )
1012+ Flipflop . stubs ( :enabled? ) . with ( :access_limited_named_users ) . returns ( true )
1013+
1014+ edition . access_limited_named_users = "user1@example.com, user2@example.com"
1015+
1016+ assert_equal 2 , edition . edition_user_accesses . count
1017+ assert_equal [ "user1@example.com" , "user2@example.com" ] ,
1018+ edition . edition_user_accesses . pluck ( :email ) . sort
1019+ end
1020+
1021+ test "access_limited_named_users= does nothing when feature is disabled" do
1022+ edition = create ( :edition )
1023+ Flipflop . stubs ( :enabled? ) . with ( :access_limited_named_users ) . returns ( false )
1024+
1025+ edition . access_limited_named_users = "user1@example.com, user2@example.com"
1026+
1027+ assert_equal 0 , edition . edition_user_accesses . count
1028+ end
1029+
10101030 def decoded_token_payload ( token )
10111031 payload , _header = JWT . decode (
10121032 token ,
You can’t perform that action at this time.
0 commit comments