diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 008f1ee96b6..769991163bc 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -323,8 +323,7 @@ class FilesController < ApplicationController end def react_files - raise ActiveRecord::RecordNotFound unless (@context.is_a?(User) ? @domain_root_account : @context).feature_enabled?(:better_file_browsing) - if tab_enabled?(@context.class::TAB_FILES) + if authorized_action(@context, @current_user, :read) && tab_enabled?(@context.class::TAB_FILES) @contexts = [@context] get_all_pertinent_contexts(include_groups: true) if @context == @current_user files_contexts = @contexts.map do |context| diff --git a/lib/feature.rb b/lib/feature.rb index e74e11fa6bb..9c6b8099156 100644 --- a/lib/feature.rb +++ b/lib/feature.rb @@ -222,8 +222,7 @@ goes to the personal files page for a user ('/files') then you need to turn it o END applies_to: 'Course', - state: 'allowed', - beta: true + state: 'on' }, 'modules_next' => { diff --git a/spec/apis/v1/files_controller_api_spec.rb b/spec/apis/v1/files_controller_api_spec.rb index 793dad00313..15bdf2f781f 100644 --- a/spec/apis/v1/files_controller_api_spec.rb +++ b/spec/apis/v1/files_controller_api_spec.rb @@ -850,7 +850,6 @@ describe "Files API", type: :request do context "with usage_rights_required" do before do @course.enable_feature! :usage_rights_required - @course.enable_feature! :better_file_browsing user_session(@teacher) @att.update_attribute(:locked, true) end diff --git a/spec/controllers/files_controller_spec.rb b/spec/controllers/files_controller_spec.rb index 712d10135d9..f86a0b3cd20 100644 --- a/spec/controllers/files_controller_spec.rb +++ b/spec/controllers/files_controller_spec.rb @@ -596,33 +596,16 @@ describe FilesController do @file.update_attribute(:locked, true) end - context "without better_file_browsing" do - before do - @course.disable_feature! :better_file_browsing - end - - it "should publish without usage rights" do - put 'update', :course_id => @course.id, :id => @file.id, :attachment => {:locked => "false"} - expect(@file.reload).not_to be_locked - end + it "should not publish if usage_rights unset" do + put 'update', :course_id => @course.id, :id => @file.id, :attachment => {:locked => "false"} + expect(@file.reload).to be_locked end - context "with better_file_browsing" do - before do - @course.enable_feature! :better_file_browsing - end - - it "should not publish if usage_rights unset" do - put 'update', :course_id => @course.id, :id => @file.id, :attachment => {:locked => "false"} - expect(@file.reload).to be_locked - end - - it "should publish if usage_rights set" do - @file.usage_rights = @course.usage_rights.create! use_justification: 'public_domain' - @file.save! - put 'update', :course_id => @course.id, :id => @file.id, :attachment => {:locked => "false"} - expect(@file.reload).not_to be_locked - end + it "should publish if usage_rights set" do + @file.usage_rights = @course.usage_rights.create! use_justification: 'public_domain' + @file.save! + put 'update', :course_id => @course.id, :id => @file.id, :attachment => {:locked => "false"} + expect(@file.reload).not_to be_locked end end end @@ -765,7 +748,6 @@ describe FilesController do end it "should create the file in locked state if :usage_rights_required is enabled" do - @course.enable_feature! :better_file_browsing @course.enable_feature! :usage_rights_required user_session(@teacher) post 'create_pending', {:attachment => { diff --git a/spec/lib/file_in_context_spec.rb b/spec/lib/file_in_context_spec.rb index d07fb2c41a2..27804dd9aae 100644 --- a/spec/lib/file_in_context_spec.rb +++ b/spec/lib/file_in_context_spec.rb @@ -46,7 +46,6 @@ describe FileInContext do describe "usage rights required" do before do - @course.enable_feature! :better_file_browsing @course.enable_feature! :usage_rights_required @filename = File.expand_path(File.join(File.dirname(__FILE__), %w(.. fixtures files a_file.txt))) end diff --git a/spec/models/content_migration/course_copy_attachments_spec.rb b/spec/models/content_migration/course_copy_attachments_spec.rb index 4213893f10e..8825d8782b2 100644 --- a/spec/models/content_migration/course_copy_attachments_spec.rb +++ b/spec/models/content_migration/course_copy_attachments_spec.rb @@ -150,7 +150,6 @@ describe ContentMigration do ur = @copy_from.usage_rights.create! use_justification: 'used_by_permission', legal_copyright: '(C) 2015 Wyndham Systems' Attachment.where(id: [attNU.id, attLU.id]).update_all(usage_rights_id: ur.id) - @copy_to.enable_feature! :better_file_browsing @copy_to.enable_feature! :usage_rights_required yield diff --git a/spec/selenium/file_spec.rb b/spec/selenium/file_spec.rb deleted file mode 100644 index c6674374934..00000000000 --- a/spec/selenium/file_spec.rb +++ /dev/null @@ -1,251 +0,0 @@ -require File.expand_path(File.dirname(__FILE__) + '/common') -require File.expand_path(File.dirname(__FILE__) + '/helpers/files_common') - -describe "shared files tests" do - include_examples "in-process server selenium tests" - - def fixture_file_path(file) - path = ActionController::TestCase.respond_to?(:fixture_path) ? ActionController::TestCase.send(:fixture_path) : nil - return "#{path}#{file}" - end - - def add_file(fixture, context, name) - context.attachments.create! do |attachment| - attachment.uploaded_data = fixture - attachment.filename = name - attachment.folder = Folder.root_folders(context).first - end - end - - def make_folder_actions_visible - driver.execute_script("$('.folder_item').addClass('folder_item_hover')") - end - - before do - local_storage! - end - - it "should make folders in the menu droppable local" do - should_make_folders_in_the_menu_droppable - end - - it "should show students link to download zip of folder local" do - should_show_students_link_to_download_zip_of_folder - end - - context "as a teacher" do - - before (:each) do - local_storage! - user_with_pseudonym :username => "nobody2@example.com", - :password => "asdfasdf2" - course_with_teacher_logged_in :user => @user - create_session(@pseudonym) - add_file(fixture_file_upload('files/html-editing-test.html', 'text/html'), - @course, "html-editing-test.html") - get "/courses/#{@course.id}/files" - keep_trying_until { expect(fj('.file')).to be_displayed } - make_folder_actions_visible - end - - it "should allow you to edit a file name" do - edit_name = 'edited html file' - fj('.file .rename_item_link:visible').click - file_name = f('#rename_entry_field') - wait_for_ajaximations - replace_content(file_name, edit_name) - wait_for_ajaximations - file_name.send_keys(:return) - wait_for_ajaximations - last_file = Folder.last.attachments.last - expect(f('#files_content')).to include_text(last_file.display_name) - end - - it "should allow you to delete a file" do - fj('.file .delete_item_link:visible').click - driver.switch_to.alert.accept - wait_for_ajaximations - last_file = Folder.last.attachments.last - last_file.file_state == 'deleted' - expect(f('#files_content')).not_to include_text(last_file.display_name) - end - - it "should allow you to lock a file" do - fj('.file .lock_item_link:visible').click - lock_form = f('#lock_attachment_form') - expect(lock_form).to be_displayed - wait_for_ajaximations - submit_form(lock_form) - wait_for_ajaximations - expect(fj('.file .item_icon:visible')).to have_attribute('alt', 'Locked File') - expect(Folder.last.attachments.last.locked).to be_truthy - end - - context 'tinyMCE html editing' do - - before (:each) do - link = keep_trying_until { f("li.editable_folder_item div.header a.download_url") } - expect(link).to be_displayed - expect(link.text).to eq "html-editing-test.html" - end - - def click_edit_link(page_refresh = true) - get "/courses/#{@course.id}/files" if page_refresh - link = keep_trying_until { f("li.editable_folder_item div.header a.edit_item_content_link") } - expect(link).to be_displayed - expect(link.text).to eq "edit content" - link.click - wait_for_ajaximations - keep_trying_until { expect(fj("#edit_content_dialog")).to be_displayed } - end - - def switch_html_edit_views - fj('.switch_views:visible').click - end - - def save_html_content - f(".ui-dialog .btn-primary").click - end - - it "should allow you to edit html files" do - current_content = File.read(fixture_file_path("files/html-editing-test.html")) - 4.times do - new_content = "#{SecureRandom.hex(10)}" - click_edit_link - keep_trying_until(120) { driver.execute_script("return $('#edit_content_textarea')[0].value;") == current_content } - driver.execute_script("$('#edit_content_textarea')[0].value = '#{new_content}';") - current_content = new_content - f(".ui-dialog .btn-primary").click - expect(f("#edit_content_dialog")).not_to be_displayed - end - end - - it "should validate adding a bold line changes the html" do - click_edit_link - wait_for_ajaximations - switch_html_edit_views - f('.mce-i-bold').click - type_in_tiny('#edit_content_textarea', 'this is bold') - fj('.switch_views:visible').click - expect(driver.execute_script("return $('#edit_content_textarea')[0].value;")).to match /this is bold<\/strong>/ - driver.execute_script("return $('#edit_content_textarea')[0].value = 'lol';") - fj('.switch_views:visible').click - fj('.switch_views:visible').click - expect(driver.execute_script("return $('#edit_content_textarea')[0].value;")).to match /lol<\/fake>/ - end - - it "should save changes from HTML view" do - click_edit_link - wait_for_ajaximations - switch_html_edit_views - type_in_tiny('#edit_content_textarea', 'I am typing') - save_html_content - wait_for_ajaximations - click_edit_link - keep_trying_until { expect(f('#edit_content_textarea')[:value]).to match /I am typing/ } - end - - it "should save changes from code view" do - click_edit_link - wait_for_ajaximations - driver.execute_script("$('#edit_content_textarea')[0].value = 'I am typing';") - wait_for_ajaximations - save_html_content - wait_for_ajaximations - click_edit_link - wait_for_ajaximations - keep_trying_until { expect(f('#edit_content_textarea')[:value]).to match /I am typing/ } - end - - it "should allow you to open and close the dialog and switch views" do - click_edit_link - keep_trying_until { expect(driver.execute_script("return $('#edit_content_textarea').is(':visible');")).to eq true } - switch_html_edit_views - expect(driver.execute_script("return $('#edit_content_textarea').is(':hidden');")).to eq true - close_visible_dialog - click_edit_link(false) - keep_trying_until { expect(driver.execute_script("return $('#edit_content_textarea').is(':visible');")).to eq true } - switch_html_edit_views - expect(driver.execute_script("return $('#edit_content_textarea').is(':hidden');")).to eq true - end - end - end - - describe "files S3 tests" do - before do - s3_storage! - end - - it "should make folders in the menu droppable s3" do - should_make_folders_in_the_menu_droppable - end - - it "should show students link to download zip of folder s3" do - should_show_students_link_to_download_zip_of_folder - end - end -end - - -describe "zip file uploads" do - include_examples "in-process server selenium tests" - - context "courses" do - before do - course_with_teacher_logged_in - @files_url = "/courses/#{@course.id}/files" - @files_import_url = "/courses/#{@course.id}/imports/files" - @context = @course - end - - it "should allow unzipping into a folder from the form courses" do - unzip_from_form_to_folder - end - - it "should allow unzipping into a folder from drag-and-drop courses" do - skip("drag and drop issues") - get @files_url - next unless driver.execute_script("return $.handlesHTML5Files;") == true - unzip_into_folder_drag_and_drop - end - end - - - context "groups" do - before do - group_with_user_logged_in(:group_context => course) - @files_url = "/groups/#{@group.id}/files" - @files_import_url = "/groups/#{@group.id}/imports/files" - @context = @group - end - - it "should allow unzipping into a folder from the form groups" do - unzip_from_form_to_folder - end - - it "should allow unzipping into a folder from drag-and-drop groups" do - get @files_url - next unless driver.execute_script("return $.handlesHTML5Files;") == true - unzip_into_folder_drag_and_drop - end - end - - context "user" do - before do - course_with_student_logged_in - @files_url = "/files" - @files_import_url = "/users/#{@user.id}/imports/files" - @context = @user - end - - it "should allow unzipping into a folder from the form profile" do - unzip_from_form_to_folder - end - - it "should allow unzipping into a folder from drag-and-drop profile" do - get @files_url - next unless driver.execute_script("return $.handlesHTML5Files;") == true - unzip_into_folder_drag_and_drop - end - end -end diff --git a/spec/selenium/files_spec.rb b/spec/selenium/files_spec.rb deleted file mode 100644 index 54489a34751..00000000000 --- a/spec/selenium/files_spec.rb +++ /dev/null @@ -1,227 +0,0 @@ -require File.expand_path(File.dirname(__FILE__) + '/common') -require File.expand_path(File.dirname(__FILE__) + '/helpers/files_common') - -describe "files" do - def add_folders(name = 'new folder', number_to_add = 1) - 1..number_to_add.times do |number| - keep_trying_until do - f(".add_folder_link").click - wait_for_ajaximations - expect(f("#files_content .add_folder_form #folder_name")).to be_displayed - end - new_folder = f("#files_content .add_folder_form #folder_name") - wait_for_ajaximations - new_folder.send_keys(name) - wait_for_ajaximations - new_folder.send_keys(:return) - wait_for_ajaximations - end - end - - def make_folder_actions_visible - driver.execute_script("$('.folder_item').addClass('folder_item_hover')") - end - - def attach_file(file_fullpath) - attachment_field = keep_trying_until do - driver.execute_script "$('.add_file_link').click()" - wait_for_ajaximations - attachment_field = fj('#attachment_uploaded_data') - expect(attachment_field).to be_displayed - attachment_field - end - attachment_field.send_keys(file_fullpath) - wait_for_ajaximations - f('.add_file_form').submit - wait_for_ajaximations - wait_for_js - end - - def get_file_elements - file_elements = keep_trying_until do - file_elements = ffj('#files_structure_list > .context > ul > .file > .name') - expect(file_elements.count).to eq 3 - file_elements - end - file_elements - end - - def file_setup - sleep 5 - @a_filename, a_fullpath, _, @a_tempfile = get_file("a_file.txt") - @b_filename, b_fullpath, _, @b_tempfile = get_file("b_file.txt") - @c_filename, c_fullpath, _, @c_tempfile = get_file("c_file.txt") - - attach_file(a_fullpath) - attach_file(c_fullpath) - attach_file(b_fullpath) - end - - describe "common file behaviors" do - include_examples "in-process server selenium tests" - - before(:each) do - course_with_teacher_logged_in - get "/files" - end - - context "when creating new folders" do - let(:folder_a_name) { "a_folder" } - let(:folder_b_name) { "b_folder" } - let(:folder_c_name) { "c_folder" } - - before(:each) do - add_folders(folder_b_name) - add_folders(folder_a_name) - add_folders(folder_c_name) - end - - it "orders file structure folders alphabetically" do - folder_elements = ff('#files_structure_list > .context > ul > .node.folder > .name') - - expect(folder_elements[0].text).to eq folder_a_name - expect(folder_elements[1].text).to eq folder_b_name - expect(folder_elements[2].text).to eq folder_c_name - end - - it "orders file content folders alphabetically" do - folder_elements = ff('#files_content > .folder_item.folder > .header > .name') - - expect(folder_elements[0].text).to eq folder_a_name - expect(folder_elements[1].text).to eq folder_b_name - expect(folder_elements[2].text).to eq folder_c_name - end - end - - context "when creating new files" do - - it "should order file structure files alphabetically" do - file_setup - file_elements = get_file_elements - - expect(file_elements[0].text).to eq @a_filename - expect(file_elements[1].text).to eq @b_filename - expect(file_elements[2].text).to eq @c_filename - end - end - - context "letter casing" do - - def add_multiple_folders(folder_names) - folder_names.each { |name| add_folders(name) } - ff('#files_content .folder') - end - - it "should ignore file name case when alphabetizing" do - amazing_filename, amazing_fullpath, _, amazing_tempfile = get_file("amazing_file.txt") - dog_filename, dog_fullpath, _, dog_tempfile = get_file("Dog_file.txt") - file_paths = [dog_fullpath, amazing_fullpath] - file_paths.each do - |name| attach_file(name) - wait_for_ajaximations - end - files = ff('#files_content .file') - expect(files.first).to include_text('amazing') - expect(files.last).to include_text('Dog') - end - - it "should ignore folder name case when alphabetizing" do - folder_names = %w(amazing Dog) - folders = add_multiple_folders(folder_names) - expect(folders.first).to include_text(folder_names[0]) - expect(folders.last).to include_text(folder_names[1]) - end - - it "should ignore mixed-casing when adding new folders" do - folder_names = %w(ZeEDeE CoOlEst) - folders = add_multiple_folders(folder_names) - expect(folders.first).to include_text(folder_names[1]) - expect(folders.last).to include_text(folder_names[0]) - end - end - end - - describe "files without s3 and forked tests" do - include_examples "in-process server selenium tests" - - before (:each) do - @folder_name = "my folder" - course_with_teacher_logged_in - get "/files" - wait_for_ajaximations - add_folders(@folder_name) - wait_for_ajaximations - expect(Folder.last.name).to eq @folder_name - @folder_css = ".folder_#{Folder.last.id}" - make_folder_actions_visible - end - - it "should allow renaming folders" do - edit_folder_name = "my folder 2" - entry_field = keep_trying_until do - f("#files_content .folder_item .rename_item_link").click - wait_for_ajaximations - entry_field = f("#files_content #rename_entry_field") - expect(entry_field).to be_displayed - entry_field - end - wait_for_ajaximations - entry_field.send_keys(edit_folder_name) - wait_for_ajaximations - entry_field.send_keys(:return) - wait_for_ajaximations - expect(Folder.last.name).to eq edit_folder_name - end - - it "should allow deleting a folder" do - f(@folder_css + ' .delete_item_link').click - driver.switch_to.alert.accept - wait_for_ajaximations - expect(Folder.last.workflow_state).to eq 'deleted' - expect(f('#files_content')).not_to include_text(@folder_name) - end - - it "should allow locking a folder" do - f(@folder_css + ' .lock_item_link').click - lock_form = f('#lock_folder_form') - expect(lock_form).to be_displayed - submit_form(lock_form) - wait_for_ajaximations - expect(f(@folder_css + ' .header img')).to have_attribute('alt', 'Locked Folder') - expect(Folder.last.locked).to be_truthy - end - end - - describe "course files" do - include_examples "in-process server selenium tests" - - it "should not show root folder files in the collaborations folder when there is a collaboration" do - course_with_teacher_logged_in - - f = Folder.root_folders(@course).first - a = f.active_file_attachments.build - a.context = @course - a.uploaded_data = default_uploaded_data - a.save! - - PluginSetting.create!(:name => 'etherpad', :settings => {}) - - @collaboration = Collaboration.typed_collaboration_instance('EtherPad') - @collaboration.context = @course - @collaboration.attributes = { :title => 'My collaboration', - :user => @teacher } - @collaboration.save! - - get "/courses/#{@course.id}/files" - wait_for_ajaximations - - file_elements = keep_trying_until do - file_elements = ffj('#files_structure_list > .context > ul > .file > .name') - expect(file_elements.count).to eq 1 - file_elements - end - - expect(file_elements.first.text).to eq a.name - end - end -end diff --git a/spec/selenium/new_files_folders_spec.rb b/spec/selenium/new_files_folders_spec.rb index 7fe4930b24b..5fdc3dec75b 100644 --- a/spec/selenium/new_files_folders_spec.rb +++ b/spec/selenium/new_files_folders_spec.rb @@ -5,9 +5,8 @@ describe "better_file_browsing, folders" do include_examples "in-process server selenium tests" context "Folders" do - before (:each) do + before(:each) do course_with_teacher_logged_in - Account.default.enable_feature!(:better_file_browsing) get "/courses/#{@course.id}/files" folder_name = "new test folder" add_folder(folder_name) @@ -82,9 +81,8 @@ describe "better_file_browsing, folders" do end context "Folder Tree" do - before (:each) do + before(:each) do course_with_teacher_logged_in - Account.default.enable_feature!(:better_file_browsing) get "/courses/#{@course.id}/files" end diff --git a/spec/selenium/new_files_spec.rb b/spec/selenium/new_files_spec.rb index 1c9ff712a7b..4008c06b3f8 100644 --- a/spec/selenium/new_files_spec.rb +++ b/spec/selenium/new_files_spec.rb @@ -6,7 +6,6 @@ describe "better_file_browsing" do context "As a teacher", priority: 1 do before(:each) do course_with_teacher_logged_in - Account.default.enable_feature!(:better_file_browsing) add_file(fixture_file_upload('files/example.pdf', 'application/pdf'), @course, "example.pdf") get "/courses/#{@course.id}/files" @@ -84,7 +83,6 @@ describe "better_file_browsing" do context "Search textbox" do before(:each) do course_with_teacher_logged_in - Account.default.enable_feature!(:better_file_browsing) txt_files = ["a_file.txt", "b_file.txt", "c_file.txt"] txt_files.map do |text_file| add_file(fixture_file_upload("files/#{text_file}", 'text/plain'), @course, text_file) @@ -106,7 +104,6 @@ describe "better_file_browsing" do context "Move dialog" do before(:each) do course_with_teacher_logged_in - Account.default.enable_feature!(:better_file_browsing) txt_files = ["a_file.txt", "b_file.txt"] txt_files.map { |text_file| add_file(fixture_file_upload("files/#{text_file}", 'text/plain'), @course, text_file) } get "/courses/#{@course.id}/files" @@ -154,7 +151,6 @@ describe "better_file_browsing" do context "Publish Cloud Dialog" do before(:each) do course_with_teacher_logged_in - Account.default.enable_feature!(:better_file_browsing) add_file(fixture_file_upload('files/a_file.txt', 'text/plain'), @course, "a_file.txt") get "/courses/#{@course.id}/files" @@ -194,7 +190,6 @@ describe "better_file_browsing" do before :each do course_with_teacher_logged_in - Account.default.enable_feature!(:better_file_browsing) Account.default.enable_feature!(:usage_rights_required) add_file(fixture_file_upload('files/a_file.txt', 'text/plan'), @course, "a_file.txt") @@ -247,7 +242,6 @@ describe "better_file_browsing" do before :each do course_with_teacher_logged_in - Account.default.enable_feature!(:better_file_browsing) Account.default.enable_feature!(:usage_rights_required) add_file(fixture_file_upload('files/a_file.txt', 'text/plan'), @course, "a_file.txt") diff --git a/spec/selenium/public_courses_spec.rb b/spec/selenium/public_courses_spec.rb index edc835364d4..29ad2fcdfbb 100644 --- a/spec/selenium/public_courses_spec.rb +++ b/spec/selenium/public_courses_spec.rb @@ -25,7 +25,7 @@ describe "public courses" do it "should display course files" do get "/courses/#{public_course.id}/files" - expect(f('#files_structure_list')).to be_displayed + expect(f('div.ef-main[data-reactid]')).to be_displayed end it "should display course syllabus" do @@ -81,17 +81,6 @@ describe "public courses" do ensure_logged_out end - context 'with draft state disabled' do - let!(:public_course) do - course(active_course: true) - @course.is_public = true - @course.save! - @course - end - - include_examples 'a public course' - end - context 'with draft state enabled' do let!(:public_course) do course(active_course: true)