bypass the wiki model as much as possible for wiki_pages

Change-Id: I60ec3b519219fcb5256a132c05f63538600df73f
Reviewed-on: https://gerrit.instructure.com/121760
Tested-by: Jenkins
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Product-Review: James Williams  <jamesw@instructure.com>
QA-Review: James Williams  <jamesw@instructure.com>
This commit is contained in:
James Williams 2017-08-07 11:28:58 -06:00
parent 39412c857e
commit 45147e0911
114 changed files with 447 additions and 466 deletions

View File

@ -374,17 +374,14 @@ class ContextController < ApplicationController
WORKFLOW_TYPES = [
:all_discussion_topics, :assignments, :assignment_groups,
:enrollments, :rubrics, :collaborations, :quizzes, :context_modules
].freeze
ITEM_TYPES = WORKFLOW_TYPES + [
:wiki_pages, :attachments
:enrollments, :rubrics, :collaborations, :quizzes, :context_modules, :wiki_pages
].freeze
ITEM_TYPES = WORKFLOW_TYPES + [:attachments].freeze
def undelete_index
if authorized_action(@context, @current_user, :manage_content)
@item_types = WORKFLOW_TYPES.select { |type| @context.class.reflections.key?(type.to_s) }.
map { |type| @context.association(type).reader }
@item_types << @context.wiki.wiki_pages if @context.respond_to? :wiki
@deleted_items = []
@item_types.each do |scope|
@deleted_items += scope.where(:workflow_state => 'deleted').limit(25).to_a

View File

@ -353,7 +353,7 @@ class ContextModuleItemsApiController < ApplicationController
item_params[:id] = params[:module_item][:content_id]
if ['Page', 'WikiPage'].include?(item_params[:type])
if page_url = params[:module_item][:page_url]
if wiki_page = @context.wiki.wiki_pages.not_deleted.where(url: page_url).first
if wiki_page = @context.wiki_pages.not_deleted.where(url: page_url).first
item_params[:id] = wiki_page.id
else
return render :json => {:message => "invalid page_url parameter"}, :status => :bad_request
@ -630,7 +630,7 @@ class ContextModuleItemsApiController < ApplicationController
else
# map wiki page url to id
if asset_type == 'WikiPage'
page = @context.wiki.wiki_pages.not_deleted.where(url: asset_id).first
page = @context.wiki_pages.not_deleted.where(url: asset_id).first
asset_id = page.id if page
else
asset_id = asset_id.to_i

View File

@ -2514,7 +2514,7 @@ class CoursesController < ApplicationController
@entries.concat(@context.discussion_topics.active.select{ |dt|
dt.published? && !dt.locked_for?(@current_user, :check_policies => true)
})
@entries.concat @context.wiki.wiki_pages
@entries.concat @context.wiki_pages
@entries = @entries.sort_by{|e| e.updated_at}
@entries.each do |entry|
feed.entries << entry.to_atom(:context => @context)

View File

@ -705,7 +705,7 @@ class GroupsController < ApplicationController
@entries = []
@entries.concat @context.calendar_events.active
@entries.concat @context.discussion_topics.active
@entries.concat @context.wiki.wiki_pages
@entries.concat @context.wiki_pages
@entries = @entries.sort_by{|e| e.updated_at}
@entries.each do |entry|
feed.entries << entry.to_atom(:context => @context)

View File

@ -383,8 +383,6 @@ class MasterCourses::MasterTemplatesController < ApplicationController
scope =
case content_type
when 'wiki_page'
@course.wiki.wiki_pages.not_deleted
when 'external_tool'
@course.context_external_tools.active
when 'attachment'
@ -430,8 +428,6 @@ class MasterCourses::MasterTemplatesController < ApplicationController
item_scope = case klass
when 'Attachment'
@course.attachments
when 'WikiPage'
@course.wiki.wiki_pages
when 'Assignment'
@course.assignments.include_submittables
when 'DiscussionTopic'

View File

@ -1904,7 +1904,7 @@ class UsersController < ApplicationController
@entries.concat context.assignments.active.where("updated_at>?", cutoff)
@entries.concat context.calendar_events.active.where("updated_at>?", cutoff)
@entries.concat context.discussion_topics.active.where("updated_at>?", cutoff)
@entries.concat context.wiki.wiki_pages.not_deleted.where("updated_at>?", cutoff)
@entries.concat context.wiki_pages.not_deleted.where("updated_at>?", cutoff)
end
@entries.each do |entry|
feed.entries << entry.to_atom(:include_context => true, :context => @context)

View File

@ -243,7 +243,7 @@ class WikiPagesApiController < ApplicationController
if authorized_action(@context.wiki, @current_user, :read) && tab_enabled?(@context.class::TAB_PAGES)
pages_route = polymorphic_url([:api_v1, @context, :wiki_pages])
# omit body from selection, since it's not included in index results
scope = @context.wiki.wiki_pages.select(WikiPage.column_names - ['body']).preload(:user)
scope = @context.wiki_pages.select(WikiPage.column_names - ['body']).preload(:user)
if params.has_key?(:published)
scope = value_to_boolean(params[:published]) ? scope.published : scope.unpublished
else

View File

@ -90,7 +90,7 @@ class WikiPagesController < ApplicationController
encoded_name = @page_name && CGI.escape(@page_name).gsub("+", " ")
redirect_to polymorphic_url([@context, :wiki_page], id: encoded_name || @page, titleize: params[:titleize], action: :edit)
else
wiki_page = @wiki.wiki_pages.deleted_last.where(url: @page.url).first
wiki_page = @context.wiki_pages.deleted_last.where(url: @page.url).first
if wiki_page && wiki_page.deleted?
flash[:warning] = t('notices.page_deleted', 'The page "%{title}" has been deleted.', :title => @page.title)
else

View File

@ -158,7 +158,7 @@ module ApplicationHelper
includes.each{|i| @wiki_sidebar_data[i] ||= [] }
if @context.respond_to?(:wiki)
limit = Setting.get('wiki_sidebar_item_limit', 1000000).to_i
@wiki_sidebar_data[:wiki_pages] = @context.wiki.wiki_pages.active.order(:title).select('title, url, workflow_state').limit(limit)
@wiki_sidebar_data[:wiki_pages] = @context.wiki_pages.active.order(:title).select('title, url, workflow_state').limit(limit)
@wiki_sidebar_data[:wiki] = @context.wiki
end
@wiki_sidebar_data[:wiki_pages] ||= []

View File

@ -691,7 +691,7 @@ class Assignment < ActiveRecord::Base
self.discussion_topic = topic
elsif self.context.feature_enabled?(:conditional_release) &&
self.submission_types == "wiki_page" && @saved_by != :wiki_page
page = self.wiki_page || self.context.wiki.wiki_pages.build(:user => @updating_user)
page = self.wiki_page || self.context.wiki_pages.build(:user => @updating_user)
save_submittable(page)
self.wiki_page = page
end

View File

@ -24,9 +24,9 @@ module BroadcastPolicies
end
def should_dispatch_updated_wiki_page?
if wiki_page.wiki && wiki_page.wiki.context
return false if wiki_page.wiki.context.concluded?
return false if wiki_page.wiki.context.respond_to?(:unpublished?) && wiki_page.wiki.context.unpublished?
if wiki_page.context
return false if wiki_page.context.concluded?
return false if wiki_page.context.respond_to?(:unpublished?) && wiki_page.wiki.context.unpublished?
end
return false unless created_before?(1.minutes.ago)
changed_while_published? || wiki_page.changed_state(:active)

View File

@ -584,8 +584,6 @@ class ContentMigration < ActiveRecord::Base
next unless MasterCourses::ALLOWED_CONTENT_TYPES.include?(klass)
mig_ids = deletions[klass]
item_scope = case klass
when 'WikiPage'
self.context.wiki.wiki_pages.not_deleted.where(migration_id: mig_ids)
when 'Attachment'
self.context.attachments.not_deleted.where(migration_id: mig_ids)
else

View File

@ -112,7 +112,7 @@ module Context
res[:modules] = self.respond_to?(:context_modules) && self.context_modules.active.exists?
res[:quizzes] = self.respond_to?(:quizzes) && self.quizzes.active.exists?
res[:assignments] = self.respond_to?(:assignments) && self.assignments.active.exists?
res[:pages] = self.respond_to?(:wiki) && self.wiki_id && self.wiki.wiki_pages.active.exists?
res[:pages] = self.respond_to?(:wiki_pages) && self.wiki_pages.active.exists?
res[:conferences] = self.respond_to?(:web_conferences) && self.web_conferences.active.exists?
res[:announcements] = self.respond_to?(:announcements) && self.announcements.active.exists?
res[:outcomes] = self.respond_to?(:has_outcomes?) && self.has_outcomes?

View File

@ -464,7 +464,7 @@ class ContextModule < ActiveRecord::Base
position = opts[:position] || (self.content_tags.not_deleted.maximum(:position) || 0) + 1
position = [position, params[:position].to_i].max if params[:position]
if params[:type] == "wiki_page" || params[:type] == "page"
item = opts[:wiki_page] || self.context.wiki.wiki_pages.where(id: params[:id]).first
item = opts[:wiki_page] || self.context.wiki_pages.where(id: params[:id]).first
elsif params[:type] == "attachment" || params[:type] == "file"
item = opts[:attachment] || self.context.attachments.not_deleted.find_by_id(params[:id])
elsif params[:type] == "assignment"

View File

@ -143,7 +143,7 @@ class Course < ActiveRecord::Base
has_many :context_external_tools, -> { order('name') }, as: :context, inverse_of: :context, dependent: :destroy
has_many :tool_proxies, class_name: 'Lti::ToolProxy', as: :context, inverse_of: :context, dependent: :destroy
belongs_to :wiki
has_many :wiki_pages, foreign_key: 'wiki_id', primary_key: 'wiki_id'
has_many :wiki_pages, as: :context, inverse_of: :context
has_many :quizzes, -> { order('lock_at, title, id') }, class_name: 'Quizzes::Quiz', as: :context, inverse_of: :context, dependent: :destroy
has_many :quiz_questions, :class_name => 'Quizzes::QuizQuestion', :through => :quizzes
has_many :active_quizzes, -> { preload(:assignment).where("quizzes.workflow_state<>'deleted'").order(:created_at) }, class_name: 'Quizzes::Quiz', as: :context, inverse_of: :context
@ -2043,7 +2043,7 @@ class Course < ActiveRecord::Base
res += self.quizzes
res += self.discussion_topics.active
res += self.discussion_entries.active
res += self.wiki.wiki_pages.active
res += self.wiki_pages.active
res += self.calendar_events.active
res
end
@ -2983,7 +2983,7 @@ class Course < ActiveRecord::Base
self.discussion_topics.touch_all
self.quizzes.touch_all
self.wiki.touch
self.wiki.wiki_pages.touch_all
self.wiki_pages.touch_all
end
end

View File

@ -55,7 +55,7 @@ class Group < ActiveRecord::Base
has_many :external_feeds, :as => :context, :inverse_of => :context, :dependent => :destroy
has_many :messages, :as => :context, :inverse_of => :context, :dependent => :destroy
belongs_to :wiki
has_many :wiki_pages, foreign_key: 'wiki_page', primary_key: 'wiki_page'
has_many :wiki_pages, as: :context, inverse_of: :context
has_many :web_conferences, :as => :context, :inverse_of => :context, :dependent => :destroy
has_many :collaborations, -> { order("#{Collaboration.quoted_table_name}.title, #{Collaboration.quoted_table_name}.created_at") }, as: :context, inverse_of: :context, dependent: :destroy
has_many :media_objects, :as => :context, :inverse_of => :context

View File

@ -199,7 +199,7 @@ module Importers
hash[:indent] = [hash[:indent] || 0, level].max
resource_class = linked_resource_type_class(hash[:linked_resource_type])
if resource_class == WikiPage
wiki = context_module.context.wiki.wiki_pages.where(migration_id: hash[:linked_resource_id]).first if hash[:linked_resource_id]
wiki = context_module.context.wiki_pages.where(migration_id: hash[:linked_resource_id]).first if hash[:linked_resource_id]
if wiki
item = context_module.add_item({
:title => wiki.title.presence || hash[:title] || hash[:linked_resource_title],

View File

@ -152,7 +152,7 @@ module Importers
if course.wiki.has_no_front_page
if migration.for_course_copy? && (source = migration.source_course || Course.where(id: migration.migration_settings[:source_course_id]).first)
mig_id = CC::CCHelper.create_key(source.wiki.front_page)
if new_front_page = course.wiki.wiki_pages.where(migration_id: mig_id).first
if new_front_page = course.wiki_pages.where(migration_id: mig_id).first
course.wiki.set_front_page_url!(new_front_page.url)
end
end

View File

@ -37,7 +37,7 @@ module Importers
def resolve_link!(link)
case link[:link_type]
when :wiki_page
if linked_wiki_url = context.wiki.wiki_pages.where(migration_id: link[:migration_id]).limit(1).pluck(:url).first
if linked_wiki_url = context.wiki_pages.where(migration_id: link[:migration_id]).limit(1).pluck(:url).first
link[:new_value] = "#{context_path}/pages/#{linked_wiki_url}"
end
when :discussion_topic

View File

@ -62,7 +62,7 @@ module Importers
hash = hash.with_indifferent_access
item ||= WikiPage.where(wiki_id: context.wiki, id: hash[:id]).first
item ||= WikiPage.where(wiki_id: context.wiki, migration_id: hash[:migration_id]).first
item ||= context.wiki.wiki_pages.temp_record
item ||= context.wiki_pages.temp_record(:wiki => context.wiki)
item.mark_as_importing!(migration)
new_record = item.new_record?
@ -135,7 +135,7 @@ module Importers
hash[:contents].each do |sub_item|
sub_item = sub_item.with_indifferent_access
if ['folder', 'FOLDER_TYPE'].member? sub_item[:type]
obj = context.wiki.wiki_pages.where(migration_id: sub_item[:migration_id]).first
obj = context.wiki_pages.where(migration_id: sub_item[:migration_id]).first
contents += " <li><a href='/courses/#{context.id}/pages/#{obj.url}'>#{obj.title}</a></li>\n" if obj
elsif sub_item[:type] == 'embedded_content'
if contents && contents.length > 0
@ -157,7 +157,7 @@ module Importers
obj = context.quizzes.where(migration_id: sub_item[:linked_resource_id]).first
contents += " <li><a href='/courses/#{context.id}/quizzes/#{obj.id}'>#{obj.title}</a></li>\n" if obj
when /PAGE_TYPE|WIKI_TYPE/
obj = context.wiki.wiki_pages.where(migration_id: sub_item[:linked_resource_id]).first
obj = context.wiki_pages.where(migration_id: sub_item[:linked_resource_id]).first
contents += " <li><a href='/courses/#{context.id}/pages/#{obj.url}'>#{obj.title}</a></li>\n" if obj
when 'FILE_TYPE'
file = context.attachments.where(migration_id: sub_item[:linked_resource_id]).first

View File

@ -103,7 +103,7 @@ class MasterCourses::ChildSubscription < ActiveRecord::Base
c.context_external_tools,
c.discussion_topics,
c.quizzes,
c.wiki.wiki_pages
c.wiki_pages
]
end
end

View File

@ -222,8 +222,6 @@ class MasterCourses::MasterTemplate < ActiveRecord::Base
item_scope = case klass
when 'Attachment'
course.attachments.where(:file_state => 'deleted')
when 'WikiPage'
course.wiki.wiki_pages.where(:workflow_state => 'deleted')
else
klass.constantize.where(:context_id => course, :context_type => 'Course', :workflow_state => 'deleted')
end

View File

@ -8,7 +8,7 @@
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FORg
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
@ -72,8 +72,7 @@ class Wiki < ActiveRecord::Base
# return an implicitly created page if a page could not be found
unless page
page = self.wiki_pages.temp_record(:title => url.titleize, :url => url)
page.wiki = self
page = self.wiki_pages.temp_record(:title => url.titleize, :url => url, :context => self.context)
end
page
end
@ -166,6 +165,7 @@ class Wiki < ActiveRecord::Base
self.shard.activate do
page = WikiPage.new(opts)
page.wiki = self
page.context = self.context
page.initialize_wiki_page(user)
page
end

View File

@ -43,21 +43,21 @@ class WikiPage < ActiveRecord::Base
after_update :post_to_pandapub_when_revised
belongs_to :wiki, :touch => true
belongs_to :course, foreign_key: 'wiki_id', primary_key: 'wiki_id'
belongs_to :group, foreign_key: 'wiki_id', primary_key: 'wiki_id'
belongs_to :user
acts_as_url :title, :scope => [:wiki_id, :not_deleted], :sync_url => true
belongs_to :context, polymorphic: [:course, :group]
acts_as_url :title, :sync_url => true
validate :validate_front_page_visibility
before_save :default_submission_values,
if: proc { self.context.try(:feature_enabled?, :conditional_release) }
before_save :set_revised_at
before_validation :ensure_wiki_and_context
before_validation :ensure_unique_title
before_save :ensure_context
after_save :touch_wiki_context
after_save :touch_context
after_save :update_assignment,
if: proc { self.context.try(:feature_enabled?, :conditional_release) }
@ -88,15 +88,17 @@ class WikiPage < ActiveRecord::Base
TITLE_LENGTH = 255
SIMPLY_VERSIONED_EXCLUDE_FIELDS = [:workflow_state, :editing_roles, :notify_of_update].freeze
def ensure_context
# TODO: get rid of once all existing wiki pages have their context populated and wiki page creation methods can be rewritten
# e.g. course.wiki.wiki_pages.create -> course.wiki_pages.create
self.context_type ||= self.context.class.base_class.name
self.context_id ||= self.context.id
def ensure_wiki_and_context
if self.context
self.wiki_id ||= self.context.wiki.id
elsif self.wiki
self.context_type ||= self.wiki.context.class.base_class.name
self.context_id ||= self.wiki.context.id
end
end
def touch_wiki_context
self.wiki.touch_context if self.wiki && self.wiki.context
def touch_context
self.context.touch
end
def validate_front_page_visibility
@ -109,13 +111,14 @@ class WikiPage < ActiveRecord::Base
return if deleted?
to_cased_title = ->(string) { string.gsub(/[^\w]+/, " ").gsub(/\b('?[a-z])/){$1.capitalize}.strip }
self.title ||= to_cased_title.call(self.url || "page")
return unless self.wiki
# TODO i18n (see wiki.rb)
scope = self.context ? self.context.wiki_pages : self.wiki.wiki_pages
if self.title == "Front Page" && self.new_record?
baddies = self.wiki.wiki_pages.not_deleted.where(title: "Front Page").select{|p| p.url != "front-page" }
baddies = scope.not_deleted.where(title: "Front Page").select{|p| p.url != "front-page" }
baddies.each{|p| p.title = to_cased_title.call(p.url); p.save_without_broadcasting! }
end
if existing = self.wiki.wiki_pages.not_deleted.where(title: self.title).first
if existing = scope.not_deleted.where(title: self.title).first
return if existing == self
real_title = self.title.gsub(/-(\d*)\z/, '') # remove any "-#" at the end
n = $1 ? $1.to_i + 1 : 2
@ -123,7 +126,7 @@ class WikiPage < ActiveRecord::Base
mod = "-#{n}"
new_title = real_title[0...(TITLE_LENGTH - mod.length)] + mod
n = n.succ
end while self.wiki.wiki_pages.not_deleted.where(title: new_title).exists?
end while scope.not_deleted.where(title: new_title).exists?
self.title = new_title
end
@ -134,6 +137,7 @@ class WikiPage < ActiveRecord::Base
end
def ensure_unique_url
return if deleted?
url_attribute = self.class.url_attribute
base_url = self.send(url_attribute)
base_url = self.send(self.class.attribute_to_urlify).to_s.to_url if base_url.blank? || !self.only_when_blank
@ -142,30 +146,16 @@ class WikiPage < ActiveRecord::Base
conditions.first << " and id != ?"
conditions << id
end
# make stringex scoping a little more useful/flexible... in addition to
# the normal constructed attribute scope(s), it also supports paramater-
# less scopeds. note that there needs to be an instance_method of
# the same name for this to work
scopes = self.class.scope_for_url ? Array(self.class.scope_for_url) : []
base_scope = self.class
scopes.each do |scope|
next unless self.respond_to?(scope)
if base_scope.respond_to?(scope)
return unless send(scope)
base_scope = base_scope.send(scope)
else
conditions.first << " and #{self.class.connection.quote_column_name(scope)} = ?"
conditions << send(scope)
end
end
url_owners = base_scope.where(conditions).to_a
scope = self.context ? self.context.wiki_pages : self.wiki.wiki_pages
urls = scope.where(*conditions).not_deleted.pluck(:url)
# This is the part in stringex that messed us up, since it will never allow
# a url of "front-page" once "front-page-1" or "front-page-2" is created
# We modify it to allow "front-page" and start the indexing at "front-page-2"
# instead of "front-page-1"
if url_owners.size > 0 && url_owners.detect{|u| u.send(url_attribute) == base_url}
if urls.size > 0 && urls.detect{|u| u == base_url}
n = 2
while url_owners.detect{|u| u.send(url_attribute) == "#{base_url}-#{n}"}
while urls.detect{|u| u == "#{base_url}-#{n}"}
n = n.succ
end
write_attribute url_attribute, "#{base_url}-#{n}"
@ -363,12 +353,6 @@ class WikiPage < ActiveRecord::Base
end
end
def context
shard.activate do
@context ||= association(:wiki).loaded? ? wiki.context : (Course.where(wiki_id: self.wiki_id).first || Group.where(wiki_id: self.wiki_id).first)
end
end
def participants
res = []
if context && context.available?

View File

@ -147,7 +147,7 @@
<%# cache on the context.wiki instead of just the context because even though it will require a db query, we will get a much better cache hit rate %>
<option value="new"><%= t :new_page_option, "[ New Page ]" %></option>
<% cache([@context.wiki, 'non_deleted_wiki_pages']) do %>
<% @context.wiki.wiki_pages.not_deleted.select([:id, :title]).each do |page| %>
<% @context.wiki_pages.not_deleted.select([:id, :title]).each do |page| %>
<% if page && !page.new_record? %>
<option value="<%= page.id %>"><%= page.title %></option>
<% end %>

View File

@ -0,0 +1,8 @@
class MakeWikiPageContextNotNull < ActiveRecord::Migration[5.0]
tag :postdeploy
def change
change_column_null :wiki_pages, :context_type, false
change_column_null :wiki_pages, :context_id, false
end
end

View File

@ -178,7 +178,7 @@ describe "Course Account Reports" do
end
it "should not find courses with objects" do
@wiki_page = @course6.wiki.wiki_pages.create(
@wiki_page = @course6.wiki_pages.create(
:title => "Some random wiki page",
:body => "wiki page content")
report = run_report(@type)

View File

@ -224,7 +224,7 @@ module Canvas::Migration::Helpers
when 'attachments'
course_attachments_data(content_list, source)
when 'wiki_pages'
source.wiki.wiki_pages.not_deleted.select("id, title, assignment_id").each do |item|
source.wiki_pages.not_deleted.select("id, title, assignment_id").each do |item|
content_list << course_item_hash(type, item)
end
when 'discussion_topics'
@ -271,9 +271,7 @@ module Canvas::Migration::Helpers
next if type == 'groups'
count = 0
if type == 'wiki_pages'
count = source.wiki.wiki_pages.not_deleted.count
elsif type == 'discussion_topics'
if type == 'discussion_topics'
count = source.discussion_topics.active.only_discussion_topics.count
elsif type == 'learning_outcomes'
count = source.linked_learning_outcomes.count

View File

@ -228,9 +228,9 @@ module CCHelper
# WikiPagesController allows loosely-matching URLs; fix them before exporting
if match.obj_id.present?
url_or_title = match.obj_id
page = @course.wiki.wiki_pages.deleted_last.where(url: url_or_title).first ||
@course.wiki.wiki_pages.deleted_last.where(url: url_or_title.to_url).first ||
@course.wiki.wiki_pages.where(id: url_or_title.to_i).first
page = @course.wiki_pages.deleted_last.where(url: url_or_title).first ||
@course.wiki_pages.deleted_last.where(url: url_or_title.to_url).first ||
@course.wiki_pages.where(id: url_or_title.to_i).first
end
if page
"#{WIKI_TOKEN}/#{match.type}/#{page.url}"

View File

@ -22,7 +22,7 @@ module CC
wiki_folder = File.join(@export_dir, CCHelper::WIKI_FOLDER)
FileUtils::mkdir_p wiki_folder
scope = @course.wiki.wiki_pages.not_deleted
scope = @course.wiki_pages.not_deleted
WikiPages::ScopedToUser.new(@course, @user, scope).scope.each do |page|
next unless export_object?(page)
next if @user && page.locked_for?(@user)

View File

@ -124,7 +124,7 @@ class CourseLinkValidator
progress.update_completion! 85
# Wiki pages
self.course.wiki.wiki_pages.not_deleted.each do |page|
self.course.wiki_pages.not_deleted.each do |page|
find_invalid_links(page.body) do |links|
self.issues << {:name => page.title, :type => :wiki_page,
:content_url => "/courses/#{self.course.id}/pages/#{page.url}"}.merge(:invalid_links => links)

View File

@ -104,7 +104,7 @@ module Lti
when 'module'
@context.context_modules.where(id: @media_types[:modules].first).first.name
when 'page'
@context.wiki.wiki_pages.where(id: @media_types[:pages].first).first.title
@context.wiki_pages.where(id: @media_types[:pages].first).first.title
when 'module_item'
tag.title
when 'quiz'
@ -156,7 +156,7 @@ module Lti
when 'modules'
@context.context_modules
when 'pages'
@context.wiki.wiki_pages
@context.wiki_pages
when 'module_items'
@context.context_module_tags
when 'quizzes'

View File

@ -31,9 +31,9 @@ describe "API Error Handling", type: :request do
end
it "should not return the base object in ActiveRecord::Errors.to_json" do
page = WikiPage.new(:body => 'blah blah', :title => 'blah blah')
expect(page.valid?).to be_falsey
errors = page.errors.to_json
assmt = Assignment.new
expect(assmt.valid?).to be_falsey
errors = assmt.errors.to_json
parsed = JSON.parse(errors)['errors']
expect(parsed.size).to be > 0
expect(errors).not_to match(/blah blah/)

View File

@ -237,7 +237,7 @@ describe UserContent, type: :request do
end
it "should not choke on funny email addresses" do
@wiki_page = @course.wiki.wiki_pages.build(:title => "title")
@wiki_page = @course.wiki_pages.build(:title => "title")
@wiki_page.body = "<a href='mailto:djmankiewicz@homestarrunner,com'>e-nail</a>"
@wiki_page.workflow_state = 'active'
@wiki_page.save!
@ -249,7 +249,7 @@ describe UserContent, type: :request do
context "data api endpoints" do
context "course context" do
it "should process links to each type of object" do
@wiki_page = @course.wiki.wiki_pages.build(:title => "title")
@wiki_page = @course.wiki_pages.build(:title => "title")
@wiki_page.body = <<-HTML
<p>
<a href='/courses/#{@course.id}/assignments'>assignments index</a>
@ -308,7 +308,7 @@ describe UserContent, type: :request do
context "group context" do
it "should process links to each type of object" do
group_with_user(:active_all => true)
@wiki_page = @group.wiki.wiki_pages.build(:title => "title")
@wiki_page = @group.wiki_pages.build(:title => "title")
@wiki_page.body = <<-HTML
<p>
<a href='/groups/#{@group.id}/wiki'>wiki index</a>

View File

@ -27,7 +27,7 @@ describe ContentExportsApiController, type: :request do
let_once(:t_course) do
course_with_teacher(user: t_teacher, active_all: true)
@course.wiki.wiki_pages.create! title: "something to export"
@course.wiki_pages.create! title: "something to export"
@course
end
@ -256,12 +256,12 @@ describe ContentExportsApiController, type: :request do
:uploaded_data => StringIO.new("more stuff"), :folder => Folder.unfiled_folder(t_course))
end
let_once :page_to_copy do
page_to_copy = t_course.wiki.wiki_pages.create!(:title => "other page")
page_to_copy = t_course.wiki_pages.create!(:title => "other page")
page_to_copy.body = "<p><a href=\"/courses/#{t_course.id}/files/#{att_to_copy.id}/preview\">hey look a link</a></p>"
page_to_copy.save!
page_to_copy
end
let_once(:page_to_not_copy){ t_course.wiki.wiki_pages.create!(:title => "another page") }
let_once(:page_to_not_copy){ t_course.wiki_pages.create!(:title => "another page") }
let_once(:mod) do
# both the wiki page and the referenced attachment should be exported implicitly through the module
mod = t_course.context_modules.create!(:name => "who cares")
@ -305,9 +305,9 @@ describe ContentExportsApiController, type: :request do
run_jobs
expect(@course.context_modules.where(migration_id: CC::CCHelper.create_key(mod))).to be_exists
copied_page = @course.wiki.wiki_pages.where(migration_id: CC::CCHelper.create_key(page_to_copy)).first
copied_page = @course.wiki_pages.where(migration_id: CC::CCHelper.create_key(page_to_copy)).first
expect(copied_page).not_to be_nil
expect(@course.wiki.wiki_pages.where(migration_id: CC::CCHelper.create_key(page_to_not_copy))).not_to be_exists
expect(@course.wiki_pages.where(migration_id: CC::CCHelper.create_key(page_to_not_copy))).not_to be_exists
copied_att = @course.attachments.where(filename: att_to_copy.filename).first
expect(copied_att).not_to be_nil
@ -345,9 +345,9 @@ describe ContentExportsApiController, type: :request do
run_jobs
expect(@course.context_modules.where(migration_id: CC::CCHelper.create_key(mod))).to be_exists
copied_page = @course.wiki.wiki_pages.where(migration_id: CC::CCHelper.create_key(page_to_copy)).first
copied_page = @course.wiki_pages.where(migration_id: CC::CCHelper.create_key(page_to_copy)).first
expect(copied_page).not_to be_nil
expect(@course.wiki.wiki_pages.where(migration_id: CC::CCHelper.create_key(page_to_not_copy))).not_to be_exists
expect(@course.wiki_pages.where(migration_id: CC::CCHelper.create_key(page_to_not_copy))).not_to be_exists
copied_att = @course.attachments.where(filename: att_to_copy.filename).first
expect(copied_att).not_to be_nil
@ -454,9 +454,9 @@ describe ContentExportsApiController, type: :request do
run_jobs
copied_page = @course.wiki.wiki_pages.where(migration_id: CC::CCHelper.create_key(page_to_copy)).first
copied_page = @course.wiki_pages.where(migration_id: CC::CCHelper.create_key(page_to_copy)).first
expect(copied_page).not_to be_nil
expect(@course.wiki.wiki_pages.where(migration_id: CC::CCHelper.create_key(page_to_not_copy))).not_to be_exists
expect(@course.wiki_pages.where(migration_id: CC::CCHelper.create_key(page_to_not_copy))).not_to be_exists
end
it "should export rubrics attached to discussions" do
@ -497,7 +497,7 @@ describe ContentExportsApiController, type: :request do
@dt1 = @course.discussion_topics.create!(:message => "hi", :title => "discussion title")
@cm = @course.context_modules.create!(:name => "some module")
@att = Attachment.create!(:filename => 'first.txt', :uploaded_data => StringIO.new('ohai'), :folder => Folder.unfiled_folder(@course), :context => @course)
@wiki = @course.wiki.wiki_pages.create!(:title => "wiki", :body => "ohai")
@wiki = @course.wiki_pages.create!(:title => "wiki", :body => "ohai")
@quiz = @course.quizzes.create!(:title => "quizz")
@quiz.did_edit

View File

@ -608,7 +608,7 @@ describe ContentMigrationsController, type: :request do
@dt1 = @course.discussion_topics.create!(:message => "hi", :title => "discussion title")
@cm = @course.context_modules.create!(:name => "some module")
@att = Attachment.create!(:filename => 'first.txt', :uploaded_data => StringIO.new('ohai'), :folder => Folder.unfiled_folder(@course), :context => @course)
@wiki = @course.wiki.wiki_pages.create!(:title => "wiki", :body => "ohai")
@wiki = @course.wiki_pages.create!(:title => "wiki", :body => "ohai")
@migration.migration_type = 'course_copy_importer'
@migration.migration_settings[:source_course_id] = @course.id
@migration.save!

View File

@ -53,7 +53,7 @@ describe "Module Items API", type: :request do
:unlock_at => @christmas,
:require_sequential_progress => true)
@module2.prerequisites = "module_#{@module1.id}"
@wiki_page = @course.wiki.wiki_pages.create!(:title => "wiki title", :body => "")
@wiki_page = @course.wiki_pages.create!(:title => "wiki title", :body => "")
@wiki_page.workflow_state = 'active'; @wiki_page.save!
@wiki_page_tag = @module2.add_item(:id => @wiki_page.id, :type => 'wiki_page')
@attachment = attachment_model(:context => @course)
@ -360,7 +360,7 @@ describe "Module Items API", type: :request do
end
it "should create with page_url for wiki page items" do
wiki_page = @course.wiki.wiki_pages.create!(:title => 'whateva i do wut i want')
wiki_page = @course.wiki_pages.create!(:title => 'whateva i do wut i want')
json = api_call(:post, "/api/v1/courses/#{@course.id}/modules/#{@module1.id}/items",
{:controller => "context_module_items_api", :action => "create", :format => "json",
@ -389,7 +389,7 @@ describe "Module Items API", type: :request do
end
it "should require a non-deleted page_url" do
page = @course.wiki.wiki_pages.create(:title => 'Deleted Page')
page = @course.wiki_pages.create(:title => 'Deleted Page')
page.workflow_state = 'deleted'
page.save!
@ -1339,7 +1339,7 @@ describe "Module Items API", type: :request do
context 'mark_as_done' do
before :once do
@module = @course.context_modules.create(:name => "mark_as_done_module")
wiki_page = @course.wiki.wiki_pages.create!(:title => "mark_as_done page", :body => "")
wiki_page = @course.wiki_pages.create!(:title => "mark_as_done page", :body => "")
wiki_page.workflow_state = 'active'
wiki_page.save!
@tag = @module.add_item(:id => wiki_page.id, :type => 'wiki_page')

View File

@ -51,7 +51,7 @@ describe "Modules API", type: :request do
:unlock_at => @christmas,
:require_sequential_progress => true)
@module2.prerequisites = "module_#{@module1.id}"
@wiki_page = @course.wiki.wiki_pages.create!(:title => "Front Page", :body => "")
@wiki_page = @course.wiki_pages.create!(:title => "Front Page", :body => "")
@wiki_page.workflow_state = 'active'; @wiki_page.save!
@wiki_page_tag = @module2.add_item(:id => @wiki_page.id, :type => 'wiki_page')
@ -325,7 +325,7 @@ describe "Modules API", type: :request do
@test_modules[2..3].each { |m| m.update_attribute(:workflow_state , 'unpublished') }
@modules_to_update = [@test_modules[1], @test_modules[3]]
@wiki_page = @course.wiki.wiki_pages.create(:title => 'Wiki Page Title')
@wiki_page = @course.wiki_pages.create(:title => 'Wiki Page Title')
@wiki_page.unpublish!
@wiki_page_tag = @test_modules[3].add_item(:id => @wiki_page.id, :type => 'wiki_page')
@ -422,7 +422,7 @@ describe "Modules API", type: :request do
@module1.workflow_state = 'unpublished'
@module1.save!
@wiki_page = @course.wiki.wiki_pages.create(:title => 'Wiki Page Title')
@wiki_page = @course.wiki_pages.create(:title => 'Wiki Page Title')
@wiki_page.unpublish!
@wiki_page_tag = @module1.add_item(:id => @wiki_page.id, :type => 'wiki_page')

View File

@ -3213,7 +3213,7 @@ describe ContentImportsController, type: :request do
@course.assignments.create!(:title => 'Assignment 1', :points_possible => 10, :assignment_group => group)
@copy_from.discussion_topics.create!(:title => "Topic 1", :message => "<p>watup?</p>")
@copy_from.syllabus_body = "haha"
@copy_from.wiki.wiki_pages.create!(:title => "some page", :body => 'hi')
@copy_from.wiki_pages.create!(:title => "some page", :body => 'hi')
@copy_from.context_external_tools.create!(:name => "new tool", :consumer_key => "key", :shared_secret => "secret", :domain => 'example.com')
Attachment.create!(:filename => 'wut.txt', :display_name => "huh?", :uploaded_data => StringIO.new('uh huh.'), :folder => Folder.unfiled_folder(@copy_from), :context => @copy_from)
@copy_from.calendar_events.create!(:title => 'event', :description => 'hi', :start_at => 1.day.from_now)
@ -3354,7 +3354,7 @@ describe ContentImportsController, type: :request do
it "should only copy wiki pages" do
run_only_copy(:wiki_pages)
check_counts 0
expect(@copy_to.wiki.wiki_pages.count).to eq 1
expect(@copy_to.wiki_pages.count).to eq 1
end
each_copy_option do |option, association|
@ -3375,7 +3375,7 @@ describe ContentImportsController, type: :request do
it "should skip copy wiki pages" do
run_except_copy(:wiki_pages)
check_counts 1
expect(@copy_to.wiki.wiki_pages.count).to eq 0
expect(@copy_to.wiki_pages.count).to eq 0
end
each_copy_option do |option, association|
it "should skip copy #{option}" do

View File

@ -299,7 +299,7 @@ describe MasterCourses::MasterTemplatesController, type: :request do
assmt = @course.assignments.create!
topic = @course.discussion_topics.create!(:message => "hi", :title => "discussion title")
page = @course.wiki.wiki_pages.create!(:title => "wiki", :body => "ohai")
page = @course.wiki_pages.create!(:title => "wiki", :body => "ohai")
quiz = @course.quizzes.create!
file = @course.attachments.create!(:filename => 'blah', :uploaded_data => default_uploaded_data)
tool = @course.context_external_tools.create!(:name => "new tool", :consumer_key => "key",
@ -344,7 +344,7 @@ describe MasterCourses::MasterTemplatesController, type: :request do
it "should use default restrictions by object type if enabled" do
assmt = @course.assignments.create!
assmt_tag = @template.content_tag_for(assmt)
page = @course.wiki.wiki_pages.create!(:title => "blah")
page = @course.wiki_pages.create!(:title => "blah")
page_tag = @template.content_tag_for(page)
assmt_restricts = {:content => true, :points => true}
@ -398,7 +398,7 @@ describe MasterCourses::MasterTemplatesController, type: :request do
@minions.last.assignments.first.update_attribute :points_possible, 11
# now push some incremental changes
@page = @master.wiki.wiki_pages.create! :title => 'Unicorn'
@page = @master.wiki_pages.create! :title => 'Unicorn'
page_tag = @template.content_tag_for(@page)
page_tag.restrictions = @template.default_restrictions
page_tag.save!
@ -431,7 +431,7 @@ describe MasterCourses::MasterTemplatesController, type: :request do
minion = @minions.first
minion_migration = minion.content_migrations.last
minion_page = minion.wiki.wiki_pages.where(migration_id: @template.migration_id_for(@page)).first
minion_page = minion.wiki_pages.where(migration_id: @template.migration_id_for(@page)).first
minion_assignment = minion.assignments.where(migration_id: @template.migration_id_for(@assignment)).first
minion_file = minion.attachments.where(migration_id: @template.migration_id_for(@file)).first
minion_quiz = minion.quizzes.where(migration_id: @template.migration_id_for(@quiz)).first
@ -485,7 +485,7 @@ describe MasterCourses::MasterTemplatesController, type: :request do
setup_template
@master = @course
@template.add_child_course!(course_factory(:name => 'Minion'))
@page = @master.wiki.wiki_pages.create! :title => 'Old News'
@page = @master.wiki_pages.create! :title => 'Old News'
@ann = @master.announcements.create! :title => 'Boring', :message => 'Yawn'
@file = attachment_model(:context => @master, :display_name => 'Some File')
@template.content_tag_for(@file).update_attribute(:restrictions, {:content => true})
@ -496,7 +496,7 @@ describe MasterCourses::MasterTemplatesController, type: :request do
it 'detects creates, updates, and deletes since the last sync' do
@ann.destroy
@file.update_attribute(:display_name, 'Renamed')
@new_page = @master.wiki.wiki_pages.create! :title => 'New News'
@new_page = @master.wiki_pages.create! :title => 'New News'
json = api_call_as_user(@admin, :get, "/api/v1/courses/#{@master.id}/blueprint_templates/default/unsynced_changes",
:controller => 'master_courses/master_templates', :format => 'json', :template_id => 'default',
@ -514,7 +514,7 @@ describe MasterCourses::MasterTemplatesController, type: :request do
it "limits result size" do
Setting.set('master_courses_history_count', '2')
3.times { |x| @master.wiki.wiki_pages.create! :title => "Page #{x}" }
3.times { |x| @master.wiki_pages.create! :title => "Page #{x}" }
json = api_call_as_user(@admin, :get, "/api/v1/courses/#{@master.id}/blueprint_templates/default/unsynced_changes",
:controller => 'master_courses/master_templates', :format => 'json', :template_id => 'default',

View File

@ -226,14 +226,14 @@ describe "Pages API", type: :request do
:course_id => @course.to_param },
{ :wiki_page => { :title => 'New Wiki Page!', :student_planner_checkbox => '1',
:body => 'hello new page', :student_todo_at => Time.zone.now}})
page = @course.wiki.wiki_pages.where(url: json['url']).first!
page = @course.wiki_pages.where(url: json['url']).first!
expect(page.todo_date).to eq Time.zone.now
}
end
it 'should update a page with a todo_date' do
todo_date = Time.zone.local(2008, 9, 1, 12, 0, 0)
Timecop.freeze(todo_date) {
page = @course.wiki.wiki_pages.create!(:title => "hrup", :todo_date => Time.zone.now)
page = @course.wiki_pages.create!(:title => "hrup", :todo_date => Time.zone.now)
api_call(:put, "/api/v1/courses/#{@course.id}/pages/#{page.url}",
{ :controller => 'wiki_pages_api', :action => 'update',
@ -246,7 +246,7 @@ describe "Pages API", type: :request do
}
end
it 'should unset page todo_date' do
page = @course.wiki.wiki_pages.create!(:title => "hrup", :todo_date => Time.zone.now)
page = @course.wiki_pages.create!(:title => "hrup", :todo_date => Time.zone.now)
api_call(:put, "/api/v1/courses/#{@course.id}/pages/#{page.url}",
{ :controller => 'wiki_pages_api', :action => 'update',
:format => 'json', :course_id => @course.to_param,
@ -258,7 +258,7 @@ describe "Pages API", type: :request do
it 'should unset page todo_date only if explicitly asked for' do
now = Time.zone.now
page = @course.wiki.wiki_pages.create!(:title => "hrup", :todo_date => now)
page = @course.wiki_pages.create!(:title => "hrup", :todo_date => now)
api_call(:put, "/api/v1/courses/#{@course.id}/pages/#{page.url}",
{ :controller => 'wiki_pages_api', :action => 'update',
:format => 'json', :course_id => @course.to_param,
@ -301,7 +301,7 @@ describe "Pages API", type: :request do
end
it "should retrieve front_page", priority: "1", test_id: 126793 do
page = @course.wiki.wiki_pages.create!(:title => "hrup", :body => "blooop")
page = @course.wiki_pages.create!(:title => "hrup", :body => "blooop")
page.set_as_front_page!
json = api_call(:get, "/api/v1/courses/#{@course.id}/front_page",
@ -342,7 +342,7 @@ describe "Pages API", type: :request do
@timestamps = %w(2013-01-01 2013-01-02 2013-01-03).map { |d| Time.zone.parse(d) }
course_with_ta :course => @course, :active_all => true
Timecop.freeze(@timestamps[0]) do # rev 1
@vpage = @course.wiki.wiki_pages.build :title => 'version test page'
@vpage = @course.wiki_pages.build :title => 'version test page'
@vpage.workflow_state = 'unpublished'
@vpage.body = 'draft'
@vpage.save!
@ -488,7 +488,7 @@ describe "Pages API", type: :request do
json = api_call(:post, "/api/v1/courses/#{@course.id}/pages",
{ :controller => 'wiki_pages_api', :action => 'create', :format => 'json', :course_id => @course.to_param },
{ :wiki_page => { :title => 'New Wiki Page!', :body => 'hello new page' }})
page = @course.wiki.wiki_pages.where(url: json['url']).first!
page = @course.wiki_pages.where(url: json['url']).first!
expect(page.title).to eq 'New Wiki Page!'
expect(page.url).to eq 'new-wiki-page'
expect(page.body).to eq 'hello new page'
@ -501,7 +501,7 @@ describe "Pages API", type: :request do
{ :controller => 'wiki_pages_api', :action => 'update_front_page', :format => 'json', :course_id => @course.to_param },
{ :wiki_page => { :title => 'New Wiki Front Page!', :body => 'hello front page' }})
expect(json['url']).to eq front_page_url
page = @course.wiki.wiki_pages.where(url: front_page_url).first!
page = @course.wiki_pages.where(url: front_page_url).first!
expect(page.is_front_page?).to be_truthy
expect(page.title).to eq 'New Wiki Front Page!'
expect(page.body).to eq 'hello front page'
@ -524,7 +524,7 @@ describe "Pages API", type: :request do
{ :controller => 'wiki_pages_api', :action => 'update_front_page', :format => 'json', :course_id => @course.to_param },
{ :wiki_page => { :title => 'New Wiki Front Page!', :published => true}})
expect(json['url']).to eq front_page_url
page = @course.wiki.wiki_pages.where(url: front_page_url).first!
page = @course.wiki_pages.where(url: front_page_url).first!
expect(page.published?).to eq(true)
end
@ -545,7 +545,7 @@ describe "Pages API", type: :request do
json = api_call(:post, "/api/v1/courses/#{@course.id}/pages",
{ :controller => 'wiki_pages_api', :action => 'create', :format => 'json', :course_id => @course.to_param },
{ :wiki_page => { :title => 'New Wiki Page', :body => 'content to process' } })
page = @course.wiki.wiki_pages.where(url: json['url']).first!
page = @course.wiki_pages.where(url: json['url']).first!
expect(page.title).to eq 'New Wiki Page'
expect(page.url).to eq 'new-wiki-page'
expect(page.body).to eq 'processed content'
@ -558,7 +558,7 @@ describe "Pages API", type: :request do
json = api_call(:post, "/api/v1/courses/#{@course.id}/pages",
{ :controller => 'wiki_pages_api', :action => 'create', :format => 'json', :course_id => @course.to_param },
{ :wiki_page => { :title => 'New Wiki Page', :body => body } })
page = @course.wiki.wiki_pages.where(url: json['url']).first!
page = @course.wiki_pages.where(url: json['url']).first!
expect(page.title).to eq 'New Wiki Page'
expect(page.url).to eq 'new-wiki-page'
expect(page.body).to include("/groups/#{@group.id}/files")
@ -569,7 +569,7 @@ describe "Pages API", type: :request do
{ :controller => 'wiki_pages_api', :action => 'create', :format => 'json', :course_id => @course.to_param },
{ :wiki_page => { :title => 'New Wiki Page!', :body => 'hello new page', :published => true, :front_page => true}})
page = @course.wiki.wiki_pages.where(url: json['url']).first!
page = @course.wiki_pages.where(url: json['url']).first!
expect(page.is_front_page?).to be_truthy
wiki = @course.wiki
@ -583,7 +583,7 @@ describe "Pages API", type: :request do
json = api_call(:post, "/api/v1/courses/#{@course.id}/pages",
{ :controller => 'wiki_pages_api', :action => 'create', :format => 'json', :course_id => @course.to_param },
{ :wiki_page => { :published => true, :title => 'New Wiki Page!', :body => 'hello new page' }})
page = @course.wiki.wiki_pages.where(url: json['url']).first!
page = @course.wiki_pages.where(url: json['url']).first!
expect(page).to be_active
expect(json['published']).to be_truthy
end
@ -592,7 +592,7 @@ describe "Pages API", type: :request do
json = api_call(:post, "/api/v1/courses/#{@course.id}/pages",
{ :controller => 'wiki_pages_api', :action => 'create', :format => 'json', :course_id => @course.to_param },
{ :wiki_page => { :published => false, :title => 'New Wiki Page!', :body => 'hello new page' }})
page = @course.wiki.wiki_pages.where(url: json['url']).first!
page = @course.wiki_pages.where(url: json['url']).first!
expect(page).to be_unpublished
expect(json['published']).to be_falsey
end
@ -606,7 +606,7 @@ describe "Pages API", type: :request do
expect(json['published']).to be_truthy
expect(@course.wiki.get_front_page_url).to eq front_page_url
page = @course.wiki.wiki_pages.where(url: front_page_url).first!
page = @course.wiki_pages.where(url: front_page_url).first!
expect(page).to be_published
end
@ -639,7 +639,7 @@ describe "Pages API", type: :request do
:course_id => @course.to_param },
{ :wiki_page => { :title => 'Assignable Page',
:assignment => { :set_assignment => true, :only_visible_to_overrides => true } }})
@course.wiki.wiki_pages.where(url: json['url']).first!
@course.wiki_pages.where(url: json['url']).first!
end
it 'unless flag is disabled' do
@ -670,7 +670,7 @@ describe "Pages API", type: :request do
end
it "should update front_page" do
page = @course.wiki.wiki_pages.create!(:title => "hrup", :body => "blooop")
page = @course.wiki_pages.create!(:title => "hrup", :body => "blooop")
page.publish
page.set_as_front_page!
@ -750,7 +750,7 @@ describe "Pages API", type: :request do
end
it "should update wiki front page url if page url is updated" do
page = @course.wiki.wiki_pages.create!(:title => "hrup")
page = @course.wiki_pages.create!(:title => "hrup")
page.set_as_front_page!
api_call(:put, "/api/v1/courses/#{@course.id}/pages/#{page.url}",
@ -780,7 +780,7 @@ describe "Pages API", type: :request do
context 'hide_from_students' do
before :once do
@test_page = @course.wiki.wiki_pages.build(:title => 'Test Page')
@test_page = @course.wiki_pages.build(:title => 'Test Page')
@test_page.workflow_state = 'active'
@test_page.save!
end
@ -815,7 +815,7 @@ describe "Pages API", type: :request do
context 'with unpublished page' do
before :once do
@unpublished_page = @course.wiki.wiki_pages.build(:title => 'Unpublished Page', :body => 'Body of unpublished page')
@unpublished_page = @course.wiki_pages.build(:title => 'Unpublished Page', :body => 'Body of unpublished page')
@unpublished_page.workflow_state = 'unpublished'
@unpublished_page.save!
@ -919,7 +919,7 @@ describe "Pages API", type: :request do
:course_id => @course.to_param, :url => @hidden_page.url },
{ :wiki_page => { :title => 'Changin\' the Title',
:assignment => { :only_visible_to_overrides => true } }})
page = @course.wiki.wiki_pages.where(url: json['url']).first!
page = @course.wiki_pages.where(url: json['url']).first!
expect(page.assignment.title).to eq 'Changin\' the Title'
expect(page.assignment.only_visible_to_overrides).to eq true
end
@ -956,7 +956,7 @@ describe "Pages API", type: :request do
:course_id => @course.to_param, :url => @hidden_page.url },
{ :wiki_page => { :title => 'Can\'t Change It',
:assignment => { :only_visible_to_overrides => true } }})
page = @course.wiki.wiki_pages.where(url: json['url']).first!
page = @course.wiki_pages.where(url: json['url']).first!
expect(page.assignment.title).to eq 'Content Page Assignment'
expect(page.assignment.only_visible_to_overrides).to eq false
end
@ -983,7 +983,7 @@ describe "Pages API", type: :request do
end
it "should not delete the front_page" do
page = @course.wiki.wiki_pages.create!(:title => "hrup", :body => "blooop")
page = @course.wiki_pages.create!(:title => "hrup", :body => "blooop")
page.set_as_front_page!
api_call(:delete, "/api/v1/courses/#{@course.id}/pages/#{page.url}",
@ -1061,7 +1061,7 @@ describe "Pages API", type: :request do
it 'should not allow update to page todo_date if student' do
todo_date = Time.zone.local(2008, 9, 1, 12, 0, 0)
Timecop.freeze(todo_date) {
page = @course.wiki.wiki_pages.create!(:title => "hrup", :todo_date => Time.zone.now)
page = @course.wiki_pages.create!(:title => "hrup", :todo_date => Time.zone.now)
api_call(:put, "/api/v1/courses/#{@course.id}/pages/#{page.url}",
{ :controller => 'wiki_pages_api', :action => 'update',
:format => 'json', :course_id => @course.to_param,
@ -1176,7 +1176,7 @@ describe "Pages API", type: :request do
describe "with students in editing_roles" do
before :once do
@editable_page = @course.wiki.wiki_pages.create! :title => 'Editable Page', :editing_roles => 'students'
@editable_page = @course.wiki_pages.create! :title => 'Editable Page', :editing_roles => 'students'
@editable_page.workflow_state = 'active'
@editable_page.save!
end
@ -1285,7 +1285,7 @@ describe "Pages API", type: :request do
context "revisions" do
before :once do
@vpage = @course.wiki.wiki_pages.build :title => 'student version test page', :body => 'draft'
@vpage = @course.wiki_pages.build :title => 'student version test page', :body => 'draft'
@vpage.workflow_state = 'unpublished'
@vpage.save! # rev 1
@ -1395,17 +1395,17 @@ describe "Pages API", type: :request do
context "group" do
before :once do
group_with_user(:active_all => true)
5.times { |i| @group.wiki.wiki_pages.create!(:title => "Group Wiki Page #{i}", :body => "<blink>Content of page #{i}</blink>") }
5.times { |i| @group.wiki_pages.create!(:title => "Group Wiki Page #{i}", :body => "<blink>Content of page #{i}</blink>") }
end
it "should list the contents of a group wiki" do
json = api_call(:get, "/api/v1/groups/#{@group.id}/pages",
{:controller=>'wiki_pages_api', :action=>'index', :format=>'json', :group_id=>@group.to_param})
expect(json.collect { |row| row['title'] }).to eq @group.wiki.wiki_pages.active.order_by_id.collect(&:title)
expect(json.collect { |row| row['title'] }).to eq @group.wiki_pages.active.order_by_id.collect(&:title)
end
it "should retrieve page content from a group wiki" do
testpage = @group.wiki.wiki_pages.last
testpage = @group.wiki_pages.last
json = api_call(:get, "/api/v1/groups/#{@group.id}/pages/#{testpage.url}",
{:controller=>'wiki_pages_api', :action=>'show', :format=>'json', :group_id=>@group.to_param, :url=>testpage.url})
expect(json['body']).to eq testpage.body
@ -1414,28 +1414,28 @@ describe "Pages API", type: :request do
it "should create a group wiki page" do
json = api_call(:post, "/api/v1/groups/#{@group.id}/pages?wiki_page[title]=newpage",
{:controller=>'wiki_pages_api', :action=>'create', :format=>'json', :group_id=>@group.to_param, :wiki_page => {'title' => 'newpage'}})
page = @group.wiki.wiki_pages.where(url: json['url']).first!
page = @group.wiki_pages.where(url: json['url']).first!
expect(page.title).to eq 'newpage'
end
it "should update a group wiki page" do
testpage = @group.wiki.wiki_pages.first
testpage = @group.wiki_pages.first
api_call(:put, "/api/v1/groups/#{@group.id}/pages/#{testpage.url}?wiki_page[body]=lolcats",
{:controller=>'wiki_pages_api', :action=>'update', :format=>'json', :group_id=>@group.to_param, :url=>testpage.url, :wiki_page => {'body' => 'lolcats'}})
expect(testpage.reload.body).to eq 'lolcats'
end
it "should delete a group wiki page" do
count = @group.wiki.wiki_pages.not_deleted.size
testpage = @group.wiki.wiki_pages.last
count = @group.wiki_pages.not_deleted.size
testpage = @group.wiki_pages.last
api_call(:delete, "/api/v1/groups/#{@group.id}/pages/#{testpage.url}",
{:controller=>'wiki_pages_api', :action=>'destroy', :format=>'json', :group_id=>@group.to_param, :url=>testpage.url})
expect(@group.reload.wiki.wiki_pages.not_deleted.size).to eq count - 1
expect(@group.reload.wiki_pages.not_deleted.size).to eq count - 1
end
context "revisions" do
before :once do
@vpage = @group.wiki.wiki_pages.create! :title => 'revision test page', :body => 'old version'
@vpage = @group.wiki_pages.create! :title => 'revision test page', :body => 'old version'
@vpage.body = 'new version'
@vpage.save!
end
@ -1483,7 +1483,7 @@ describe "Pages API", type: :request do
assignment = @course.assignments.create!(assignment_opts)
assignment.submission_types = 'wiki_page'
assignment.save!
page = @course.wiki.wiki_pages.build(
page = @course.wiki_pages.build(
user: @teacher,
editing_roles: "teachers,students",
title: assignment_opts[:title])
@ -1555,7 +1555,7 @@ describe "Pages API", type: :request do
@assignment_2, @page_assigned_to_all = create_page_for_da(
title: "assigned to all",
only_visible_to_overrides: false)
@page_unassigned = @course.wiki.wiki_pages.create!(
@page_unassigned = @course.wiki_pages.create!(
title: "definitely not assigned",
user: @teacher,
editing_roles: "teachers,students")

View File

@ -963,7 +963,7 @@ describe CoursesController do
@course.show_announcements_on_home_page = true
@course.home_page_announcement_limit = 5
@course.save!
@course.wiki.wiki_pages.create!(:title => 'blah').set_as_front_page!
@course.wiki_pages.create!(:title => 'blah').set_as_front_page!
end
it "should populate js_env with course_home setting" do
@ -990,13 +990,13 @@ describe CoursesController do
@master_course = course_factory
@template = MasterCourses::MasterTemplate.set_as_master_course(@course)
@master_page = @course.wiki.wiki_pages.create!(:title => "blah", :body => "bloo")
@master_page = @course.wiki_pages.create!(:title => "blah", :body => "bloo")
@tag = @template.content_tag_for(@master_page)
@child_course = course_factory
@template.add_child_course!(@child_course)
@child_page = @child_course.wiki.wiki_pages.create!(:title => "bloo", :body => "bloo", :migration_id => @tag.migration_id)
@child_page = @child_course.wiki_pages.create!(:title => "bloo", :body => "bloo", :migration_id => @tag.migration_id)
end
it "should populate master-side data (unrestricted)" do

View File

@ -358,7 +358,7 @@ describe ContextController do
it 'allows undeleting wiki pages' do
# wiki pages are special because they have to go through context.wiki
user_session(@teacher)
page = @course.wiki.wiki_pages.create(:title => "some page")
page = @course.wiki_pages.create(:title => "some page")
page.workflow_state = 'deleted'
page.save!
@ -379,7 +379,7 @@ describe ContextController do
describe "GET 'roster_user_usage'" do
before(:once) do
page = @course.wiki.wiki_pages.create(:title => "some page")
page = @course.wiki_pages.create(:title => "some page")
AssetUserAccess.create!({
user_id: @student,
asset_code: page.asset_string,

View File

@ -398,10 +398,10 @@ describe ContextModulesController do
it "should reorder unpublished items" do
course_with_teacher_logged_in(active_all: true)
pageA = @course.wiki.wiki_pages.create title: "pageA"
pageA = @course.wiki_pages.create title: "pageA"
pageA.workflow_state = 'unpublished'
pageA.save
pageB = @course.wiki.wiki_pages.create! title: "pageB"
pageB = @course.wiki_pages.create! title: "pageB"
m1 = @course.context_modules.create!
tagB = m1.add_item({type: "wiki_page", id: pageB.id}, nil, position: 1)
expect(tagB).to be_published
@ -576,7 +576,7 @@ describe ContextModulesController do
student_in_course(:active_all => true)
@module = @course.context_modules.create!(:name => "first module")
@module.publish
@wiki = @course.wiki.wiki_pages.create!(:title => "wiki", :body => 'hi')
@wiki = @course.wiki_pages.create!(:title => "wiki", :body => 'hi')
@tag = @module.add_item(:id => @wiki.id, :type => 'wiki_page')
@module.completion_requirements = {@tag.id => {:type => 'must_view'}}
@ -964,7 +964,7 @@ describe ContextModulesController do
end
it "should 404 if module item is not a graded type" do
page = @course.wiki.wiki_pages.create title: "test"
page = @course.wiki_pages.create title: "test"
item = @mod.add_item type: 'page', id: page.id
get 'item_redirect_mastery_paths', params: {:course_id => @course.id, :id => item.id}

View File

@ -845,7 +845,7 @@ describe CoursesController do
it "should work for wiki view with draft state enabled" do
@course1.default_view = "wiki"
@course1.save!
@course1.wiki.wiki_pages.create!(:title => 'blah').set_as_front_page!
@course1.wiki_pages.create!(:title => 'blah').set_as_front_page!
get 'show', params: {:id => @course1.id}
expect(controller.js_env[:WIKI_RIGHTS].symbolize_keys).to eql({:read => true})
expect(controller.js_env[:PAGE_RIGHTS].symbolize_keys).to eql({:read => true})
@ -857,7 +857,7 @@ describe CoursesController do
@course1.show_announcements_on_home_page = true
@course1.home_page_announcement_limit = 3
@course1.save!
@course1.wiki.wiki_pages.create!(:title => 'blah').set_as_front_page!
@course1.wiki_pages.create!(:title => 'blah').set_as_front_page!
get 'show', params: {:id => @course1.id}
expect(controller.js_env[:COURSE_HOME]).to be_truthy
expect(controller.js_env[:SHOW_ANNOUNCEMENTS]).to be_truthy
@ -870,7 +870,7 @@ describe CoursesController do
@course1.home_page_announcement_limit = 3
@course1.is_public = true
@course1.save!
@course1.wiki.wiki_pages.create!(:title => 'blah').set_as_front_page!
@course1.wiki_pages.create!(:title => 'blah').set_as_front_page!
remove_user_session
get 'show', params: {:id => @course1.id}
expect(response).to be_success

View File

@ -320,7 +320,7 @@ describe ExternalToolsController do
it "sends content item json for a page" do
user_session(@teacher)
page = @course.wiki.wiki_pages.create!(title: 'a page')
page = @course.wiki_pages.create!(title: 'a page')
get :show, params: {:course_id => @course.id, id: @tool.id, :pages => [page.id]}
placement = JSON.parse(assigns[:lti_launch].params['content_items'])['@graph'].first
migration_url = placement['placementOf']['@id']
@ -334,7 +334,7 @@ describe ExternalToolsController do
it "sends content item json for selected content" do
user_session(@teacher)
page = @course.wiki.wiki_pages.create!(title: 'a page')
page = @course.wiki_pages.create!(title: 'a page')
assignment = @course.assignments.create!(name: 'an assignment')
get :show, params: {:course_id => @course.id, id: @tool.id, :pages => [page.id], :assignments => [assignment.id]}
placement = JSON.parse(assigns[:lti_launch].params['content_items'])['@graph'].first

View File

@ -208,7 +208,7 @@ describe PlannerOverridesController do
time = 4.days.from_now
@assignment.update_attribute(:due_at, time)
@assignment2.update_attribute(:due_at, time)
page = @course.wiki.wiki_pages.create!(:title => "t1", :todo_date => time)
page = @course.wiki_pages.create!(:title => "t1", :todo_date => time)
note = planner_note_model(:todo_date => time)
discussion = discussion_topic_model(context: @course, todo_date: time)

View File

@ -90,7 +90,7 @@ describe ContextModule do
end
it "should progress for wiki pages" do
@page = @course.wiki.wiki_pages.create!(:title => "talk page", :body => 'ohai', :editing_roles => 'teachers,students')
@page = @course.wiki_pages.create!(:title => "talk page", :body => 'ohai', :editing_roles => 'teachers,students')
@tag = @module.add_item(:type => 'wiki_page', :id => @page.id)
before_after do
put "/api/v1/courses/#{@course.id}/pages/#{@page.url}", params: {:wiki_page => { :body => 'i agree', :title => 'talk page' }}
@ -216,7 +216,7 @@ describe ContextModule do
it "should progress to a wiki page" do
[true, false].each do |progress_type|
progression_testing(progress_type) do |content|
page = @course.wiki.wiki_pages.create!(:title => "wiki", :body => content)
page = @course.wiki_pages.create!(:title => "wiki", :body => content)
@test_url = "/courses/#{@course.id}/pages/#{page.url}"
@tag2 = @mod2.add_item(:type => 'wiki_page', :id => page.id)
expect(@tag2).to be_published

View File

@ -36,7 +36,7 @@ describe LiveEvents do
context 'Wiki Pages' do
def create_page(attrs)
page = @course.wiki.wiki_pages.create!(attrs)
page = @course.wiki_pages.create!(attrs)
page.publish! if page.unpublished?
page
end

View File

@ -73,7 +73,7 @@ context "accessing public content" do
end
it "should show wiki pages" do
page = @course.wiki.wiki_pages.create!(:title => "stuff")
page = @course.wiki_pages.create!(:title => "stuff")
test_public_access do
get "/courses/#{@course.id}/pages/#{page.url}"

View File

@ -26,7 +26,7 @@ describe WikiPagesController do
end
def create_page(attrs)
page = @course.wiki.wiki_pages.create!(attrs)
page = @course.wiki_pages.create!(attrs)
page.publish! if page.unpublished?
page
end
@ -50,7 +50,7 @@ describe WikiPagesController do
course_with_teacher_logged_in(:active_all => true, :user => user_with_pseudonym)
group_category = @course.group_categories.build(:name => "mygroup")
@group = Group.create!(:name => "group1", :group_category => group_category, :context => @course)
@wiki_page = @group.wiki.wiki_pages.create :title => 'hello', :body => 'This is a wiki page.'
@wiki_page = @group.wiki_pages.create :title => 'hello', :body => 'This is a wiki page.'
def test_page(url)
get url
@ -71,7 +71,7 @@ describe WikiPagesController do
it "should work with account group wiki pages" do
group = Account.default.groups.create!
group.add_user(@user)
group_page = group.wiki.wiki_pages.create!(title: "ponies5ever", body: "")
group_page = group.wiki_pages.create!(title: "ponies5ever", body: "")
get "/groups/#{group.id}/pages/#{group_page.url}"
expect(response).to be_successful
@ -124,7 +124,7 @@ describe WikiPagesController do
it "should load as many pages as the setting allows" do
Setting.get('wiki_sidebar_item_limit', 3)
4.times{ |i| @course.wiki.wiki_pages.create!(:title => "Page #{i}") }
4.times{ |i| @course.wiki_pages.create!(:title => "Page #{i}") }
get "/courses/#{@course.id}/pages/page-1/edit"
doc = Nokogiri::HTML(response.body)

View File

@ -131,7 +131,7 @@ describe Canvas::LiveEvents do
describe ".wiki_page_updated" do
before(:each) do
course_with_teacher
@page = @course.wiki.wiki_pages.create(:title => "old title", :body => "old body")
@page = @course.wiki_pages.create(:title => "old title", :body => "old body")
end
def wiki_page_updated

View File

@ -184,7 +184,7 @@ describe Canvas::Migration::Helpers::SelectiveContentFormatter do
@topic = @course.discussion_topics.create!(:message => "hi", :title => "discussion title")
@cm = @course.context_modules.create!(:name => "some module")
attachment_model(:context => @course, :filename => 'a5.html')
@wiki = @course.wiki.wiki_pages.create!(:title => "wiki", :body => "ohai")
@wiki = @course.wiki_pages.create!(:title => "wiki", :body => "ohai")
@category = @course.group_categories.create(:name => "other category")
@group = Group.create!(:name=>"group1", :group_category => @category, :context => @course)
@announcement = announcement_model

View File

@ -26,7 +26,7 @@ describe "Common Cartridge exporting" do
course = course_model
user = user_model
message = "fail"
allow(course).to receive(:wiki).and_raise(message)
allow(course).to receive(:wiki_pages).and_raise(message)
content_export = ContentExport.new
content_export.context = course
content_export.user = user
@ -121,8 +121,8 @@ describe "Common Cartridge exporting" do
@cm1 = @course.context_modules.create!(:name => "another module")
@att = Attachment.create!(:filename => 'first.txt', :uploaded_data => StringIO.new('ohai'), :folder => Folder.unfiled_folder(@course), :context => @course)
@att2 = Attachment.create!(:filename => 'second.txt', :uploaded_data => StringIO.new('ohai'), :folder => Folder.unfiled_folder(@course), :context => @course)
@wiki = @course.wiki.wiki_pages.create!(:title => "wiki", :body => "ohai")
@wiki2 = @course.wiki.wiki_pages.create!(:title => "wiki2", :body => "ohais")
@wiki = @course.wiki_pages.create!(:title => "wiki", :body => "ohai")
@wiki2 = @course.wiki_pages.create!(:title => "wiki2", :body => "ohais")
@event = @course.calendar_events.create!(:title => "event", :start_at =>1.week.from_now)
@event1 = @course.calendar_events.create!(:title => "event2", :start_at =>2.weeks.from_now)
@bank = @course.assessment_question_banks.create!(:title => 'bank')
@ -469,7 +469,7 @@ describe "Common Cartridge exporting" do
allow(CC::CCHelper).to receive(:media_object_info).and_return({asset: {id: 1, status: '2'}, filename: 'blah.flv'})
obj = @course.media_objects.create! media_id: '0_deadbeef'
track = obj.media_tracks.create! kind: 'subtitles', locale: 'tlh', content: "Hab SoSlI' Quch!"
page = @course.wiki.wiki_pages.create!(:title => "wiki", :body => "ohai")
page = @course.wiki_pages.create!(:title => "wiki", :body => "ohai")
page.body = %Q{<a id="media_comment_0_deadbeef" class="instructure_inline_media_comment video_comment"></a>}
page.save!
@ce.export_type = ContentExport::COMMON_CARTRIDGE
@ -648,7 +648,7 @@ describe "Common Cartridge exporting" do
assignment = @course.assignments.create!({title: 'assignment', unlock_at: 5.days.from_now})
quiz = @course.quizzes.create!(title: 'quiz', unlock_at: 5.days.from_now)
topic = @course.discussion_topics.create!(title: 'topic', unlock_at: 5.days.from_now)
page = @course.wiki.wiki_pages.create!(:title => "wiki", :body => "ohai")
page = @course.wiki_pages.create!(:title => "wiki", :body => "ohai")
mod = @course.context_modules.create!(:name => "some module")
mod.add_item(type: 'page', id: page.id)
mod.unlock_at = 5.days.from_now

View File

@ -149,7 +149,7 @@ describe CC::CCHelper do
allow(HostUrl).to receive(:protocol).and_return('http')
allow(HostUrl).to receive(:context_host).and_return('www.example.com:8080')
@exporter = CC::CCHelper::HtmlContentExporter.new(@course, @user, :for_course_copy => false)
page = @course.wiki.wiki_pages.create(:title => '9000, the level is over')
page = @course.wiki_pages.create(:title => '9000, the level is over')
html = <<-HTML
<a href="/courses/#{@course.id}/wiki/#{page.url}">This course's wiki page</a>
HTML
@ -162,7 +162,7 @@ describe CC::CCHelper do
allow(HostUrl).to receive(:protocol).and_return('http')
allow(HostUrl).to receive(:context_host).and_return('www.example.com:8080')
@exporter = CC::CCHelper::HtmlContentExporter.new(@course, @user, :for_course_copy => false)
page = @course.wiki.wiki_pages.create(:title => '9000')
page = @course.wiki_pages.create(:title => '9000')
html = <<-HTML
<a href="/courses/#{@course.id}/wiki/#{page.url}">This course's wiki page</a>
HTML

View File

@ -473,7 +473,7 @@ describe "Canvas Cartridge importing" do
tag = mod1.add_item({:id => asmnt1.id, :type => 'assignment', :indent => 1})
c_reqs = []
c_reqs << {:type => 'min_score', :min_score => 5, :id => tag.id}
page = @copy_from.wiki.wiki_pages.create!(:title => "some page")
page = @copy_from.wiki_pages.create!(:title => "some page")
tag = mod1.add_item({:id => page.id, :type => 'wiki_page'})
c_reqs << {:type => 'must_view', :id => tag.id}
mod1.completion_requirements = c_reqs
@ -483,7 +483,7 @@ describe "Canvas Cartridge importing" do
asmnt2 = @copy_to.assignments.create(:title => "some assignment")
asmnt2.migration_id = CC::CCHelper.create_key(asmnt1)
asmnt2.save!
page2 = @copy_to.wiki.wiki_pages.create(:title => "some page")
page2 = @copy_to.wiki_pages.create(:title => "some page")
page2.migration_id = CC::CCHelper.create_key(page)
page2.save!
@ -574,7 +574,7 @@ describe "Canvas Cartridge importing" do
<a href="/courses/%s/files/%s/download?wrap=1">Download (wrap) File</a>
<a href="/courses/%s/files/%s/bogus?someattr=1">Download (wrap) File</a>
</p>}
page = @copy_from.wiki.wiki_pages.create!(:title => "some page", :body => body_with_link % ([ @copy_from.id, attachment.id ] * 4))
page = @copy_from.wiki_pages.create!(:title => "some page", :body => body_with_link % ([ @copy_from.id, attachment.id ] * 4))
@copy_from.save!
#export to html file
@ -589,7 +589,7 @@ describe "Canvas Cartridge importing" do
Importers::WikiPageImporter.import_from_migration(hash, @copy_to, @migration)
@migration.resolve_content_links!
page_2 = @copy_to.wiki.wiki_pages.where(migration_id: migration_id).first
page_2 = @copy_to.wiki_pages.where(migration_id: migration_id).first
expect(page_2.title).to eq page.title
expect(page_2.url).to eq page.url
expect(page_2.body).to eq body_with_link % ([ @copy_to.id, attachment_import.id ] * 4)
@ -623,7 +623,7 @@ describe "Canvas Cartridge importing" do
Importers::WikiPageImporter.import_from_migration(hash, @copy_to, @migration)
@migration.resolve_content_links!
page_2 = @copy_to.wiki.wiki_pages.where(migration_id: hash[:migration_id]).first
page_2 = @copy_to.wiki_pages.where(migration_id: hash[:migration_id]).first
links = Nokogiri::HTML::DocumentFragment.parse(page_2.body).css("a")
expect(links.count).to eq 2
expect(links.first['href']).to eq "/media_objects/#{media_id}"
@ -632,8 +632,8 @@ describe "Canvas Cartridge importing" do
it "should import wiki pages" do
# make sure that the wiki page we're linking to in the test below exists
@copy_from.wiki.wiki_pages.create!(:title => "assignments", :body => "ohai")
@copy_to.wiki.wiki_pages.create!(:title => "assignments", :body => "ohai")
@copy_from.wiki_pages.create!(:title => "assignments", :body => "ohai")
@copy_to.wiki_pages.create!(:title => "assignments", :body => "ohai")
mod = @copy_from.context_modules.create!(:name => "some module")
mod2 = @copy_to.context_modules.create(:name => "some module")
mod2.migration_id = CC::CCHelper.create_key(mod)
@ -662,7 +662,7 @@ describe "Canvas Cartridge importing" do
<div><img src="http://www.instructure.com/images/header-logo.png"></div>
<div><img src="http://www.instructure.com/images/header-logo.png"></div>
</div>}
page = @copy_from.wiki.wiki_pages.create!(:title => "some page", :body => body_with_link % [ @copy_from.id, @copy_from.id, @copy_from.id, @copy_from.id, @copy_from.id, mod.id, @copy_from.id, from_att.id ], :editing_roles => "teachers", :notify_of_update => true)
page = @copy_from.wiki_pages.create!(:title => "some page", :body => body_with_link % [ @copy_from.id, @copy_from.id, @copy_from.id, @copy_from.id, @copy_from.id, mod.id, @copy_from.id, from_att.id ], :editing_roles => "teachers", :notify_of_update => true)
page.workflow_state = 'unpublished'
@copy_from.save!
@ -683,7 +683,7 @@ describe "Canvas Cartridge importing" do
expect(ErrorReport.last.message).to match /nil wiki/
page_2 = @copy_to.wiki.wiki_pages.where(migration_id: migration_id).first
page_2 = @copy_to.wiki_pages.where(migration_id: migration_id).first
expect(page_2.title).to eq page.title
expect(page_2.url).to eq page.url
expect(page_2.editing_roles).to eq page.editing_roles
@ -694,7 +694,7 @@ describe "Canvas Cartridge importing" do
it "should import migrate inline external tool URLs in wiki pages" do
# make sure that the wiki page we're linking to in the test below exists
page = @copy_from.wiki.wiki_pages.create!(:title => "blti-link", :body => "<a href='/courses/#{@copy_from.id}/external_tools/retrieve?url=#{CGI.escape('http://www.example.com')}'>link</a>")
page = @copy_from.wiki_pages.create!(:title => "blti-link", :body => "<a href='/courses/#{@copy_from.id}/external_tools/retrieve?url=#{CGI.escape('http://www.example.com')}'>link</a>")
@copy_from.save!
#export to html file
@ -707,7 +707,7 @@ describe "Canvas Cartridge importing" do
#import into new course
Importers::WikiPageImporter.import_from_migration(hash, @copy_to, @migration)
page_2 = @copy_to.wiki.wiki_pages.where(migration_id: migration_id).first
page_2 = @copy_to.wiki_pages.where(migration_id: migration_id).first
expect(page_2.title).to eq page.title
expect(page_2.url).to eq page.url
expect(page_2.body).to match(/\/courses\/#{@copy_to.id}\/external_tools\/retrieve/)
@ -1408,7 +1408,7 @@ XML
migration.migration_settings[:migration_ids_to_import] = {:copy => {"everything" => 1}}
Importers::CourseContentImporter.import_content(@copy_to, data, nil, migration)
wiki = @copy_to.wiki.wiki_pages.where(migration_id: "i642b8969dbfa332fd96ec9029e96156a").first
wiki = @copy_to.wiki_pages.where(migration_id: "i642b8969dbfa332fd96ec9029e96156a").first
expect(migration.migration_issues.count).to eq 1
warning = migration.migration_issues.first
expect(warning.issue_type).to eq "warning"

View File

@ -293,7 +293,7 @@ describe "Standard Common Cartridge importing" do
expect(@course.context_external_tools.first.migration_id).to eq "I_00011_R"
expect(@course.context_modules.count).to eq 1
expect(@course.context_modules.first.migration_id).to eq 'I_00000'
expect(@course.wiki.wiki_pages.count).to eq 0
expect(@course.wiki_pages.count).to eq 0
expect(@course.discussion_topics.count).to eq 1
expect(@course.discussion_topics.first.migration_id).to eq 'I_00006_R'
end

View File

@ -47,7 +47,7 @@ describe CourseLinkValidator do
topic = @course.discussion_topics.create!(:title => "discussion title", :message => html)
mod = @course.context_modules.create!(:name => "some module")
tag = mod.add_item(:type => 'external_url', :url => bad_url, :title => 'pls view')
page = @course.wiki.wiki_pages.create!(:title => "wiki", :body => html)
page = @course.wiki_pages.create!(:title => "wiki", :body => html)
quiz = @course.quizzes.create!(:title => 'quiz1', :description => html)
qq = quiz.quiz_questions.create!(:question_data => aq.question_data)
@ -183,10 +183,10 @@ describe CourseLinkValidator do
it "should find links to wiki pages" do
course_factory
active = @course.wiki.wiki_pages.create!(:title => "active and stuff")
unpublished = @course.wiki.wiki_pages.create!(:title => "unpub")
active = @course.wiki_pages.create!(:title => "active and stuff")
unpublished = @course.wiki_pages.create!(:title => "unpub")
unpublished.unpublish!
deleted = @course.wiki.wiki_pages.create!(:title => "baleeted")
deleted = @course.wiki_pages.create!(:title => "baleeted")
deleted.destroy
active_link = "/courses/#{@course.id}/pages/#{active.url}"
@ -289,7 +289,7 @@ describe CourseLinkValidator do
it "should not flag wiki pages with url encoding" do
course_factory
page = @course.wiki.wiki_pages.create!(:title => "semi;colon", :body => 'sutff')
page = @course.wiki_pages.create!(:title => "semi;colon", :body => 'sutff')
@course.syllabus_body = %{<a href='/courses/#{@course.id}/pages/#{CGI.escape(page.title)}'>link</a>}
@course.save!

View File

@ -42,21 +42,21 @@ describe ImportedHtmlConverter do
it "should convert a wiki reference" do
test_string = %{<a href="%24WIKI_REFERENCE%24/wiki/test-wiki-page">Test Wiki Page</a>}
@course.wiki.wiki_pages.create!(:title => "Test Wiki Page", :body => "stuff")
@course.wiki_pages.create!(:title => "Test Wiki Page", :body => "stuff")
expect(convert_and_replace(test_string)).to eq %{<a href="#{@path}pages/test-wiki-page">Test Wiki Page</a>}
end
it "should convert a wiki reference without $ escaped" do
test_string = %{<a href="$WIKI_REFERENCE$/wiki/test-wiki-page">Test Wiki Page</a>}
@course.wiki.wiki_pages.create!(:title => "Test Wiki Page", :body => "stuff")
@course.wiki_pages.create!(:title => "Test Wiki Page", :body => "stuff")
expect(convert_and_replace(test_string)).to eq %{<a href="#{@path}pages/test-wiki-page">Test Wiki Page</a>}
end
it "should convert a wiki reference by migration id" do
test_string = %{<a href="wiki_page_migration_id=123456677788">Test Wiki Page</a>}
wiki = @course.wiki.wiki_pages.create(:title => "Test Wiki Page", :body => "stuff")
wiki = @course.wiki_pages.create(:title => "Test Wiki Page", :body => "stuff")
wiki.migration_id = "123456677788"
wiki.save!

View File

@ -96,7 +96,7 @@ describe Lti::ContentItemResponse do
end
it 'sets the media_type to "page"' do
context_module = context.context_modules.create!(name: 'a module')
page = context.wiki.wiki_pages.create!(title: 'a page')
page = context.wiki_pages.create!(title: 'a page')
tag = context_module.add_item(:id => page.id, :type => 'page')
content_item_response = subject({module_items: [tag.id]})
expect(content_item_response.media_type).to eq 'page'
@ -155,7 +155,7 @@ describe Lti::ContentItemResponse do
end
it 'gets the title for a page' do
page = context.wiki.wiki_pages.create!(title: 'a page')
page = context.wiki_pages.create!(title: 'a page')
content_item_response = subject({pages: [page.id]})
expect(content_item_response.title).to eq 'a page'
end

View File

@ -22,7 +22,7 @@ describe "MustViewModuleProgressor" do
def create_item(item_type)
case item_type
when :page
@course.wiki.wiki_pages.create!(title: 'some page')
@course.wiki_pages.create!(title: 'some page')
when :assignment
@course.assignments.create!(title: 'some assignment')
when :discussion
@ -64,11 +64,11 @@ describe "MustViewModuleProgressor" do
def sequential_module_progression_fixture(assignment_requirement_type: 'must_view')
mod = @course.context_modules.create!(name: 'some module')
initial_page = @course.wiki.wiki_pages.create!(title: "initial page")
initial_page = @course.wiki_pages.create!(title: "initial page")
initial_page_tag = mod.add_item(id: initial_page.id, type: 'page')
assignment = @course.assignments.create!(title: "some assignment")
assignment_tag = mod.add_item(id: assignment.id, type: 'assignment')
final_page = @course.wiki.wiki_pages.create!(title: "some page")
final_page = @course.wiki_pages.create!(title: "some page")
final_page_tag = mod.add_item(id: final_page.id, type: 'page')
mod.completion_requirements = {
initial_page_tag.id => {type: 'must_view'},

View File

@ -608,7 +608,7 @@ describe UserMerge do
it "should update other appropriate versions" do
course_factory(active_all: true)
wiki_page = @course.wiki.wiki_pages.create(:title => "Hi", :user_id => user2.id)
wiki_page = @course.wiki_pages.create(:title => "Hi", :user_id => user2.id)
ra = rubric_assessment_model(:context => @course, :user => user2)
expect(wiki_page.versions).to be_present

View File

@ -24,11 +24,11 @@ describe 'DataFixup::FixImportedWikiPageWorkflow' do
@wiki_pages = []
5.times do |n|
mod = @course.context_modules.create!(:name => "module")
page = @course.wiki.wiki_pages.create!(:title => "wiki page #{n}", :body => "whatevaa")
page = @course.wiki_pages.create!(:title => "wiki page #{n}", :body => "whatevaa")
mod.add_item(:id => page.id, :type => 'wiki_page')
@wiki_pages << page
dummy_page = @course.wiki.wiki_pages.create!(:title => "ignore this wiki page #{n}", :body => "whatevaa")
dummy_page = @course.wiki_pages.create!(:title => "ignore this wiki page #{n}", :body => "whatevaa")
mod.add_item(:id => dummy_page.id, :type => 'wiki_page')
end
WikiPage.where(:id => @wiki_pages).update_all(:workflow_state => 'unpublished')

View File

@ -39,6 +39,7 @@ module BroadcastPolicies
allow(w).to receive(:created_at).and_return(1.hour.ago)
allow(w).to receive(:published?).and_return(true)
allow(w).to receive(:wiki).and_return(wiki)
allow(w).to receive(:context).and_return(course)
allow(w).to receive(:just_created).and_return(false)
end
end

View File

@ -264,8 +264,8 @@ describe ContentMigration do
mod1 = @copy_from.context_modules.create!(:name => "some module")
asmnt1 = @copy_from.assignments.create!(:title => "some assignment")
mod1.add_item({:id => asmnt1.id, :type => 'assignment', :indent => 1})
page = @copy_from.wiki.wiki_pages.create!(:title => "some page")
page2 = @copy_from.wiki.wiki_pages.create!(:title => "some page 2")
page = @copy_from.wiki_pages.create!(:title => "some page")
page2 = @copy_from.wiki_pages.create!(:title => "some page 2")
mod1.add_item({:id => page.id, :type => 'wiki_page'})
att = Attachment.create!(:filename => 'first.png', :uploaded_data => StringIO.new('ohai'), :folder => Folder.root_folders(@copy_from).first, :context => @copy_from)
att2 = Attachment.create!(:filename => 'first.png', :uploaded_data => StringIO.new('ohai'), :folder => Folder.root_folders(@copy_from).first, :context => @copy_from)
@ -305,7 +305,7 @@ describe ContentMigration do
expect(@copy_to.assignments.where(migration_id: mig_id(asmnt1)).first).not_to be_nil
expect(@copy_to.wiki.wiki_pages.where(migration_id: mig_id(page)).first).not_to be_nil
expect(@copy_to.wiki_pages.where(migration_id: mig_id(page)).first).not_to be_nil
expect(@copy_to.attachments.where(migration_id: mig_id(att)).first).not_to be_nil
expect(@copy_to.context_external_tools.where(migration_id: mig_id(tool)).first).not_to be_nil
expect(@copy_to.discussion_topics.where(migration_id: mig_id(topic)).first).not_to be_nil
@ -314,7 +314,7 @@ describe ContentMigration do
expect(@copy_to.context_modules.where(migration_id: mig_id(mod2)).first).to be_nil
expect(@copy_to.assignments.where(migration_id: mig_id(asmnt2)).first).to be_nil
expect(@copy_to.attachments.where(migration_id: mig_id(att2)).first).to be_nil
expect(@copy_to.wiki.wiki_pages.where(migration_id: mig_id(page2)).first).to be_nil
expect(@copy_to.wiki_pages.where(migration_id: mig_id(page2)).first).to be_nil
expect(@copy_to.context_external_tools.where(migration_id: mig_id(tool2)).first).to be_nil
expect(@copy_to.discussion_topics.where(migration_id: mig_id(topic2)).first).to be_nil
expect(@copy_to.quizzes.where(migration_id: mig_id(quiz2)).first).to be_nil

View File

@ -88,7 +88,7 @@ describe ContentMigration do
asmnt_des = %{<a href="/courses/%s/files/%s/preview">First file</a>}
wiki_body = %{<img src="/courses/%s/files/%s/preview">}
asmnt = @copy_from.assignments.create!(:points_possible => 40, :grading_type => 'points', :description=>(asmnt_des % [@copy_from.id, att.id]), :title => "assignment")
wiki = @copy_from.wiki.wiki_pages.create!(:title => "wiki", :body => (wiki_body % [@copy_from.id, att2.id]))
wiki = @copy_from.wiki_pages.create!(:title => "wiki", :body => (wiki_body % [@copy_from.id, att2.id]))
# don't mark the attachments
@cm.copy_options = {
@ -105,7 +105,7 @@ describe ContentMigration do
expect(att2_2).not_to be_nil
expect(@copy_to.assignments.first.description).to eq asmnt_des % [@copy_to.id, att_2.id]
expect(@copy_to.wiki.wiki_pages.first.body).to eq wiki_body % [@copy_to.id, att2_2.id]
expect(@copy_to.wiki_pages.first.body).to eq wiki_body % [@copy_to.id, att2_2.id]
end
it "should preserve links to re-uploaded attachments" do
@ -114,7 +114,7 @@ describe ContentMigration do
new_att = Attachment.create!(:filename => 'first.png', :uploaded_data => StringIO.new('ohai'), :folder => Folder.root_folders(@copy_from).first, :context => @copy_from)
expect(@copy_from.attachments.find(att.id)).to eq new_att
page = @copy_from.wiki.wiki_pages.create!(:title => "some page", :body => "<a href='/courses/#{@copy_from.id}/files/#{att.id}/download?wrap=1'>link</a>")
page = @copy_from.wiki_pages.create!(:title => "some page", :body => "<a href='/courses/#{@copy_from.id}/files/#{att.id}/download?wrap=1'>link</a>")
@cm.copy_options = { :wiki_pages => {mig_id(page) => "1"}}
@cm.save!
@ -122,7 +122,7 @@ describe ContentMigration do
run_course_copy
att2 = @copy_to.attachments.where(filename: 'first.png').first
page2 = @copy_to.wiki.wiki_pages.where(migration_id: mig_id(page)).first
page2 = @copy_to.wiki_pages.where(migration_id: mig_id(page)).first
expect(page2.body).to include("<a href=\"/courses/#{@copy_to.id}/files/#{att2.id}/download?wrap=1\">link</a>")
end

View File

@ -63,7 +63,7 @@ describe ContentMigration do
cm = @copy_from.context_modules.create!(:name => "some module")
item = cm.add_item(:id => assmt.id, :type => 'assignment')
att = Attachment.create!(:filename => 'first.txt', :uploaded_data => StringIO.new('ohai'), :folder => Folder.unfiled_folder(@copy_from), :context => @copy_from)
page = @copy_from.wiki.wiki_pages.create!(:title => "wiki", :body => "ohai")
page = @copy_from.wiki_pages.create!(:title => "wiki", :body => "ohai")
quiz = @copy_from.quizzes.create!
allow(TestExternalContentService).to receive(:applies_to_course?).and_return(true)
@ -90,7 +90,7 @@ describe ContentMigration do
copied_cm = @copy_to.context_modules.where(:migration_id => mig_id(cm)).first
copied_item = @copy_to.context_module_tags.where(:migration_id => mig_id(item)).first
copied_att = @copy_to.attachments.where(:migration_id => mig_id(att)).first
copied_page = @copy_to.wiki.wiki_pages.where(:migration_id => mig_id(page)).first
copied_page = @copy_to.wiki_pages.where(:migration_id => mig_id(page)).first
copied_quiz = @copy_to.quizzes.where(:migration_id => mig_id(quiz)).first
expect(TestExternalContentService.course).to eq @copy_to

View File

@ -169,13 +169,13 @@ describe ContentMigration do
asmnt1 = @copy_from.assignments.create!(:title => "some assignment")
tag = mod1.add_item({:id => asmnt1.id, :type => 'assignment', :indent => 1})
body = %{<p>Link to module item: <a href="/courses/%s/modules/items/%s">some assignment</a></p>}
page = @copy_from.wiki.wiki_pages.create!(:title => "some page", :body => body % [@copy_from.id, tag.id])
page = @copy_from.wiki_pages.create!(:title => "some page", :body => body % [@copy_from.id, tag.id])
run_course_copy
mod1_to = @copy_to.context_modules.where(migration_id: mig_id(mod1)).first
tag_to = mod1_to.content_tags.first
page_to = @copy_to.wiki.wiki_pages.where(migration_id: mig_id(page)).first
page_to = @copy_to.wiki_pages.where(migration_id: mig_id(page)).first
expect(page_to.body).to eq body % [@copy_to.id, tag_to.id]
end
@ -232,7 +232,7 @@ describe ContentMigration do
body += "<a class='instructure_file_link' href='/courses/#{@copy_from.id}/files/#{att2.id}/download'>link</a>"
body += "<img src='/courses/#{@copy_from.id}/files/#{img.id}/preview'>"
dt = @copy_from.discussion_topics.create!(:message => body, :title => "discussion title")
page = @copy_from.wiki.wiki_pages.create!(:title => "some page", :body => body)
page = @copy_from.wiki_pages.create!(:title => "some page", :body => body)
run_course_copy
@ -240,7 +240,7 @@ describe ContentMigration do
att_to2 = @copy_to.attachments.where(migration_id: mig_id(att2)).first
img_to = @copy_to.attachments.where(migration_id: mig_id(img)).first
page_to = @copy_to.wiki.wiki_pages.where(migration_id: mig_id(page)).first
page_to = @copy_to.wiki_pages.where(migration_id: mig_id(page)).first
expect(page_to.body).to include "/courses/#{@copy_to.id}/files/#{att_to1.id}/download"
expect(page_to.body).to include "/courses/#{@copy_to.id}/files/#{att_to2.id}/download"
expect(page_to.body).to include "/courses/#{@copy_to.id}/files/#{img_to.id}/preview"
@ -259,8 +259,8 @@ describe ContentMigration do
cm2 = @copy_from.context_modules.create!(:name => "another module")
att = Attachment.create!(:filename => 'first.txt', :uploaded_data => StringIO.new('ohai'), :folder => Folder.unfiled_folder(@copy_from), :context => @copy_from)
att2 = Attachment.create!(:filename => 'second.txt', :uploaded_data => StringIO.new('ohai'), :folder => Folder.unfiled_folder(@copy_from), :context => @copy_from)
wiki = @copy_from.wiki.wiki_pages.create!(:title => "wiki", :body => "ohai")
wiki2 = @copy_from.wiki.wiki_pages.create!(:title => "wiki2", :body => "ohais")
wiki = @copy_from.wiki_pages.create!(:title => "wiki", :body => "ohai")
wiki2 = @copy_from.wiki_pages.create!(:title => "wiki2", :body => "ohais")
data = [{:points => 3,:description => "Outcome row",:id => 1,:ratings => [{:points => 3,:description => "Rockin'",:criterion_id => 1,:id => 2}]}]
rub1 = @copy_from.rubrics.build(:title => "rub1")
rub1.data = data
@ -313,8 +313,8 @@ describe ContentMigration do
expect(@copy_to.attachments.where(migration_id: mig_id(att)).first).not_to be_nil
expect(@copy_to.attachments.where(migration_id: mig_id(att2)).first).to be_nil
expect(@copy_to.wiki.wiki_pages.where(migration_id: mig_id(wiki)).first).not_to be_nil
expect(@copy_to.wiki.wiki_pages.where(migration_id: mig_id(wiki2)).first).to be_nil
expect(@copy_to.wiki_pages.where(migration_id: mig_id(wiki)).first).not_to be_nil
expect(@copy_to.wiki_pages.where(migration_id: mig_id(wiki2)).first).to be_nil
expect(@copy_to.rubrics.where(migration_id: mig_id(rub1)).first).not_to be_nil
expect(@copy_to.rubrics.where(migration_id: mig_id(rub2)).first).to be_nil
@ -330,7 +330,7 @@ describe ContentMigration do
dt1 = @copy_from.discussion_topics.create!(:message => "hi", :title => "discussion title")
cm = @copy_from.context_modules.create!(:name => "some module")
att = Attachment.create!(:filename => 'first.txt', :uploaded_data => StringIO.new('ohai'), :folder => Folder.unfiled_folder(@copy_from), :context => @copy_from)
wiki = @copy_from.wiki.wiki_pages.create!(:title => "wiki", :body => "ohai")
wiki = @copy_from.wiki_pages.create!(:title => "wiki", :body => "ohai")
quiz = @copy_from.quizzes.create! if Qti.qti_enabled?
ag = @copy_from.assignment_groups.create!(:name => 'empty group')
asmnt = @copy_from.assignments.create!(:title => "some assignment")
@ -361,7 +361,7 @@ describe ContentMigration do
@copy_to.discussion_topics.where(migration_id: mig_id(dt1)).first.destroy
@copy_to.context_modules.where(migration_id: mig_id(cm)).first.destroy
@copy_to.attachments.where(migration_id: mig_id(att)).first.destroy
@copy_to.wiki.wiki_pages.where(migration_id: mig_id(wiki)).first.destroy
@copy_to.wiki_pages.where(migration_id: mig_id(wiki)).first.destroy
@copy_to.rubrics.where(migration_id: mig_id(rub1)).first.destroy
@copy_to.created_learning_outcomes.where(migration_id: mig_id(lo)).first.destroy
@copy_to.quizzes.where(migration_id: mig_id(quiz)).first.destroy if Qti.qti_enabled?
@ -385,7 +385,7 @@ describe ContentMigration do
expect(@copy_to.context_modules.where(migration_id: mig_id(cm)).first.workflow_state).to eq 'active'
expect(@copy_to.attachments.count).to eq 1
expect(@copy_to.attachments.where(migration_id: mig_id(att)).first.file_state).to eq 'available'
expect(@copy_to.wiki.wiki_pages.where(migration_id: mig_id(wiki)).first.workflow_state).to eq 'active'
expect(@copy_to.wiki_pages.where(migration_id: mig_id(wiki)).first.workflow_state).to eq 'active'
rub2 = @copy_to.rubrics.where(migration_id: mig_id(rub1)).first
expect(rub2.workflow_state).to eq 'active'
expect(rub2.rubric_associations.first.bookmarked).to eq true
@ -528,7 +528,7 @@ describe ContentMigration do
it "should sync module items (even when removed) on re-copy" do
mod = @copy_from.context_modules.create!(:name => "some module")
page = @copy_from.wiki.wiki_pages.create(:title => "some page")
page = @copy_from.wiki_pages.create(:title => "some page")
tag1 = mod.add_item({:id => page.id, :type => 'wiki_page'})
asmnt = @copy_from.assignments.create!(:title => "some assignment")
tag2 = mod.add_item({:id => asmnt.id, :type => 'assignment', :indent => 1})
@ -654,14 +654,14 @@ describe ContentMigration do
it "should not desync imported module item published status with existing content" do
asmnt = @copy_from.assignments.create!(:title => "some assignment")
page = @copy_from.wiki.wiki_pages.create!(:title => "some page")
page = @copy_from.wiki_pages.create!(:title => "some page")
run_course_copy
new_asmnt = @copy_to.assignments.where(:migration_id => mig_id(asmnt)).first
new_asmnt.unpublish!
new_page = @copy_to.wiki.wiki_pages.where(:migration_id => mig_id(page)).first
new_page = @copy_to.wiki_pages.where(:migration_id => mig_id(page)).first
new_page.unpublish!
mod1 = @copy_from.context_modules.create!(:name => "some module")
@ -680,7 +680,7 @@ describe ContentMigration do
end
it "should restore deleted module items on re-import" do
page = @copy_from.wiki.wiki_pages.create!(:title => "some page")
page = @copy_from.wiki_pages.create!(:title => "some page")
mod = @copy_from.context_modules.create!(:name => "some module")
tag1 = mod.add_item({ :title => 'Example 1', :type => 'external_url', :url => 'http://derp.derp/something' })

View File

@ -53,7 +53,7 @@ describe ContentMigration do
it "should copy links to unpublished items in modules" do
mod1 = @copy_from.context_modules.create!(:name => "some module")
page = @copy_from.wiki.wiki_pages.create(:title => "some page")
page = @copy_from.wiki_pages.create(:title => "some page")
page.workflow_state = :unpublished
page.save!
mod1.add_item({:id => page.id, :type => 'wiki_page'})
@ -91,13 +91,13 @@ describe ContentMigration do
end
it "should copy unpublished wiki pages" do
wiki = @copy_from.wiki.wiki_pages.create(:title => "wiki", :body => "ohai")
wiki = @copy_from.wiki_pages.create(:title => "wiki", :body => "ohai")
wiki.workflow_state = :unpublished
wiki.save!
run_course_copy
wiki2 = @copy_to.wiki.wiki_pages.where(migration_id: mig_id(wiki)).first
wiki2 = @copy_to.wiki_pages.where(migration_id: mig_id(wiki)).first
expect(wiki2.workflow_state).to eq 'unpublished'
end
@ -141,7 +141,7 @@ describe ContentMigration do
topic = @copy_from.discussion_topics.create!(:title => "some topic")
tags << mod.add_item({ :id => topic.id, :type => 'discussion_topic' })
page = @copy_from.wiki.wiki_pages.create!(:title => "some page")
page = @copy_from.wiki_pages.create!(:title => "some page")
tags << mod.add_item({ :id => page.id, :type => 'wiki_page' })
file = @copy_from.attachments.create!(:display_name => "some file", :uploaded_data => default_uploaded_data, :locked => true)

View File

@ -22,23 +22,23 @@ describe ContentMigration do
include_examples "course copy"
it "should copy wiki page attributes" do
page = @copy_from.wiki.wiki_pages.create!(:title => "title", :body => "<p>butter</p>",
page = @copy_from.wiki_pages.create!(:title => "title", :body => "<p>butter</p>",
:editing_roles => "teachers", :todo_date => Time.zone.now)
run_course_copy
page_to = @copy_to.wiki.wiki_pages.where(migration_id: mig_id(page)).first
page_to = @copy_to.wiki_pages.where(migration_id: mig_id(page)).first
attrs = [:title, :body, :editing_roles, :todo_date]
expect(page.attributes.slice(*attrs)).to eq page_to.attributes.slice(*attrs)
end
it "should reset user on re-import" do
page = @copy_from.wiki.wiki_pages.create!(:title => "reset me", :body => "<p>blah</p>")
page = @copy_from.wiki_pages.create!(:title => "reset me", :body => "<p>blah</p>")
run_course_copy
page_to = @copy_to.wiki.wiki_pages.where(migration_id: mig_id(page)).first
page_to = @copy_to.wiki_pages.where(migration_id: mig_id(page)).first
page_to.body = "something else"
page_to.user = user_factory
page_to.save!
@ -51,15 +51,15 @@ describe ContentMigration do
end
it "should not escape links to wiki urls" do
page1 = @copy_from.wiki.wiki_pages.create!(:title => "keepthese%20percent signs", :body => "blah")
page1 = @copy_from.wiki_pages.create!(:title => "keepthese%20percent signs", :body => "blah")
body = %{<p>Link to module item: <a href="/courses/%s/pages/%s#header">some assignment</a></p>}
page2 = @copy_from.wiki.wiki_pages.create!(:title => "some page", :body => body % [@copy_from.id, page1.url])
page2 = @copy_from.wiki_pages.create!(:title => "some page", :body => body % [@copy_from.id, page1.url])
run_course_copy
page1_to = @copy_to.wiki.wiki_pages.where(migration_id: mig_id(page1)).first
page2_to = @copy_to.wiki.wiki_pages.where(migration_id: mig_id(page2)).first
page1_to = @copy_to.wiki_pages.where(migration_id: mig_id(page1)).first
page2_to = @copy_to.wiki_pages.where(migration_id: mig_id(page2)).first
expect(page2_to.body).to eq body % [@copy_to.id, page1_to.url]
end
@ -71,32 +71,32 @@ describe ContentMigration do
main_page = @copy_from.wiki.front_page
main_page.body = %{<a href="/courses/#{@copy_from.id}/wiki/online:-unit-pages">wut</a>}
main_page.save!
@copy_from.wiki.wiki_pages.create!(:title => "Online: Unit Pages", :body => %{<a href="/courses/#{@copy_from.id}/wiki/#{main_page.id}">whoa</a>})
@copy_from.wiki_pages.create!(:title => "Online: Unit Pages", :body => %{<a href="/courses/#{@copy_from.id}/wiki/#{main_page.id}">whoa</a>})
run_course_copy
expect(@copy_to.wiki.front_page.body).to eq %{<a href="/courses/#{@copy_to.id}/#{@copy_to.wiki.path}/online-unit-pages">wut</a>}
expect(@copy_to.wiki.wiki_pages.where(url: "online-unit-pages").first!.body).to eq %{<a href="/courses/#{@copy_to.id}/#{@copy_to.wiki.path}/#{main_page.url}">whoa</a>}
expect(@copy_to.wiki_pages.where(url: "online-unit-pages").first!.body).to eq %{<a href="/courses/#{@copy_to.id}/#{@copy_to.wiki.path}/#{main_page.url}">whoa</a>}
end
it "should keep assignment relationship" do
vanilla_page_from = @copy_from.wiki.wiki_pages.create!(title: "Everyone Sees This Page")
vanilla_page_from = @copy_from.wiki_pages.create!(title: "Everyone Sees This Page")
wiki_page_assignment_model(course: @copy_from, title: "conditional page")
run_course_copy
page_to = @copy_to.wiki.wiki_pages.where(migration_id: mig_id(@page)).take!
page_to = @copy_to.wiki_pages.where(migration_id: mig_id(@page)).take!
asg_to = @copy_to.assignments.where(migration_id: mig_id(@assignment)).take!
expect(asg_to.wiki_page).to eq page_to
vanilla_page_to = @copy_to.wiki.wiki_pages.where(migration_id: mig_id(vanilla_page_from)).take!
vanilla_page_to = @copy_to.wiki_pages.where(migration_id: mig_id(vanilla_page_from)).take!
expect(vanilla_page_to.assignment).to be_nil
end
it "re-imports updated/deleted page" do
page = @copy_from.wiki.wiki_pages.create!(:title => "blah", :body => "<p>orig</p>")
page = @copy_from.wiki_pages.create!(:title => "blah", :body => "<p>orig</p>")
run_course_copy
page_to = @copy_to.wiki.wiki_pages.where(migration_id: mig_id(page)).first
page_to = @copy_to.wiki_pages.where(migration_id: mig_id(page)).first
page_to.destroy
page.body = '<p>updated</p>'
@ -111,18 +111,18 @@ describe ContentMigration do
context "wiki front page" do
it "should copy wiki front page setting if there is no front page" do
fake_front_page = @copy_from.wiki.wiki_pages.create!(:title => "Front Page")
real_front_page = @copy_from.wiki.wiki_pages.create!(:title => "actual front page")
fake_front_page = @copy_from.wiki_pages.create!(:title => "Front Page")
real_front_page = @copy_from.wiki_pages.create!(:title => "actual front page")
@copy_from.wiki.set_front_page_url!(real_front_page.url)
run_course_copy
new_front_page = @copy_to.wiki.wiki_pages.where(migration_id: mig_id(real_front_page)).first
new_front_page = @copy_to.wiki_pages.where(migration_id: mig_id(real_front_page)).first
expect(@copy_to.wiki.front_page).to eq new_front_page
end
it "should not set 'Front Page' as the front page" do
fake_front_page = @copy_from.wiki.wiki_pages.create!(:title => "Front Page")
fake_front_page = @copy_from.wiki_pages.create!(:title => "Front Page")
run_course_copy
@ -131,10 +131,10 @@ describe ContentMigration do
end
it "should not overwrite current front page" do
copy_from_front_page = @copy_from.wiki.wiki_pages.create!(:title => "stuff and stuff")
copy_from_front_page = @copy_from.wiki_pages.create!(:title => "stuff and stuff")
@copy_from.wiki.set_front_page_url!(copy_from_front_page.url)
copy_to_front_page = @copy_to.wiki.wiki_pages.create!(:title => "stuff and stuff and even more stuf")
copy_to_front_page = @copy_to.wiki_pages.create!(:title => "stuff and stuff and even more stuf")
@copy_to.wiki.set_front_page_url!(copy_to_front_page.url)
run_course_copy
@ -143,10 +143,10 @@ describe ContentMigration do
end
it "should overwrite current front page if default_view setting is also changed to wiki" do
copy_from_front_page = @copy_from.wiki.wiki_pages.create!(:title => "stuff and stuff")
copy_from_front_page = @copy_from.wiki_pages.create!(:title => "stuff and stuff")
@copy_from.wiki.set_front_page_url!(copy_from_front_page.url)
copy_to_front_page = @copy_to.wiki.wiki_pages.create!(:title => "stuff and stuff and even more stuf")
copy_to_front_page = @copy_to.wiki_pages.create!(:title => "stuff and stuff and even more stuf")
@copy_to.wiki.set_front_page_url!(copy_to_front_page.url)
@copy_from.update_attribute(:default_view, 'wiki')
@ -156,15 +156,15 @@ describe ContentMigration do
@copy_to.reload
expect(@copy_to.default_view).to eq 'wiki'
new_front_page = @copy_to.wiki.wiki_pages.where(:migration_id => mig_id(copy_from_front_page)).first
new_front_page = @copy_to.wiki_pages.where(:migration_id => mig_id(copy_from_front_page)).first
expect(@copy_to.wiki.front_page).to eq new_front_page
end
it "should remain with no front page if other front page is not selected for copy" do
front_page = @copy_from.wiki.wiki_pages.create!(:title => "stuff and stuff")
front_page = @copy_from.wiki_pages.create!(:title => "stuff and stuff")
@copy_from.wiki.set_front_page_url!(front_page.url)
other_page = @copy_from.wiki.wiki_pages.create!(:title => "stuff and other stuff")
other_page = @copy_from.wiki_pages.create!(:title => "stuff and other stuff")
@copy_to.wiki.unset_front_page!

View File

@ -92,7 +92,7 @@ describe ContentTag do
end
end
end
describe "#sync_workflow_state_to_asset?" do
it "true when content_type is Quiz" do
content_tag = ContentTag.new(:content_type => "Quiz")
@ -162,17 +162,17 @@ describe ContentTag do
expect(tag.content_type).to eql('DiscussionTopic')
expect(tag.content_id).to eql(5)
end
it "should not allow setting an invalid content_asset_string" do
tag = ContentTag.new
tag.content_asset_string = 'bad_class_41'
expect(tag.content_type).to eql(nil)
expect(tag.content_id).to eql(nil)
tag.content_asset_string = 'bad_class'
expect(tag.content_type).to eql(nil)
expect(tag.content_id).to eql(nil)
tag.content_asset_string = 'course_55'
expect(tag.content_type).to eql(nil)
expect(tag.content_id).to eql(nil)
@ -223,7 +223,7 @@ describe ContentTag do
expect(tags).not_to be_empty
expect(tags.any?{ |t| t.id == tag.id }).to be_truthy
end
it "should not rename the linked external tool if the tag is renamed" do
course_factory
@tool = @course.context_external_tools.create!(:name => "new tool", :consumer_key => "key", :shared_secret => "secret", :domain => 'example.com', :custom_fields => {'a' => '1', 'b' => '2'})
@ -240,7 +240,7 @@ describe ContentTag do
@tag.reload
expect(@tag.title).to eq "Example"
end
it "should not rename the tag if the linked external tool is renamed" do
course_factory
@tool = @course.context_external_tools.create!(:name => "new tool", :consumer_key => "key", :shared_secret => "secret", :domain => 'example.com', :custom_fields => {'a' => '1', 'b' => '2'})
@ -273,7 +273,7 @@ describe ContentTag do
@assignment.reload
expect(@assignment.title).to eq 'some assignment (renamed)'
end
it "should rename the tag if the linked assignment is renamed" do
course_factory
@assignment = @course.assignments.create!(:title => "some assignment")
@ -321,7 +321,7 @@ describe ContentTag do
@quiz.publish!
@quiz.reload
ContentTag.update_for @quiz
@tag.reload
@ -332,7 +332,7 @@ describe ContentTag do
it "should not attempt to update asset name attribute if it's over the db limit" do
course_factory
@page = @course.wiki.wiki_pages.create!(:title => "some page")
@page = @course.wiki_pages.create!(:title => "some page")
@module = @course.context_modules.create!(:name => "module")
@tag = @module.add_item({:type => 'WikiPage', :title => 'oh noes!' * 35, :id => @page.id})
@ -356,7 +356,7 @@ describe ContentTag do
it "should publish/unpublish the tag if the linked wiki page is published/unpublished" do
course_factory
@page = @course.wiki.wiki_pages.create!(:title => "some page")
@page = @course.wiki_pages.create!(:title => "some page")
@page.workflow_state = 'unpublished'
@page.save!
@module = @course.context_modules.create!(:name => "module")
@ -378,7 +378,7 @@ describe ContentTag do
it "should publish/unpublish the linked wiki page (and its tags) if the tag is published/unpublished" do
course_factory
@page = @course.wiki.wiki_pages.create!(:title => "some page")
@page = @course.wiki_pages.create!(:title => "some page")
@page.workflow_state = 'unpublished'
@page.save!
@module = @course.context_modules.create!(:name => "module")
@ -435,7 +435,7 @@ describe ContentTag do
@tag.save!
@tag.update_asset_workflow_state!
end
it "should not rename tag if linked attachment is renamed" do
course_factory
att = Attachment.create!(:filename => 'important title.txt', :display_name => "important title.txt", :uploaded_data => StringIO.new("It's what's on the inside of the file that doesn't matter.'"), :folder => Folder.unfiled_folder(@course), :context => @course)
@ -443,13 +443,13 @@ describe ContentTag do
a_module = @course.context_modules.create!(:name => "module")
tag = a_module.add_item({ :type => 'attachment', :title => 'important title.txt', :id => att.id })
tag.update_asset_name!
att.display_name = "no longer important.txt"
ContentTag.update_for(att)
tag.reload
expect(tag.title).to eq 'important title.txt'
end
it "should not rename attachment if linked tag is renamed" do
course_factory
att = Attachment.create!(:filename => 'important title.txt', :display_name => "important title.txt", :uploaded_data => StringIO.new("It's what's on the inside of the file that doesn't matter.'"), :folder => Folder.unfiled_folder(@course), :context => @course)
@ -457,7 +457,7 @@ describe ContentTag do
a_module = @course.context_modules.create!(:name => "module")
tag = a_module.add_item({ :type => 'attachment', :title => 'Differently Important Title', :id => att.id })
tag.update_asset_name!
att.reload
expect(att.display_name).to eq 'important title.txt'
end
@ -593,7 +593,7 @@ describe ContentTag do
end
context "other" do
it "it properly returns wiki pages" do
@page = @course.wiki.wiki_pages.create!(:title => "some page")
@page = @course.wiki_pages.create!(:title => "some page")
@module = @course.context_modules.create!(:name => "module")
@tag = @module.add_item({:type => 'WikiPage', :title => 'oh noes!' * 35, :id => @page.id})
expect(ContentTag.visible_to_students_in_course_with_da(@student.id, @course.id)).to include(@tag)

View File

@ -176,7 +176,7 @@ describe ContextModule do
it "should add a wiki page" do
course_module
@page = @course.wiki.wiki_pages.create!(:title => "some page")
@page = @course.wiki_pages.create!(:title => "some page")
@tag = @module.add_item({:id => @page.id, :type => 'wiki_page'}) #@page)
expect(@tag.content).to eql(@page)
@ -187,7 +187,7 @@ describe ContextModule do
course_module
@course.wiki
other_course = Account.default.courses.create!
@page = other_course.wiki.wiki_pages.create!(:title => "new page")
@page = other_course.wiki_pages.create!(:title => "new page")
@tag = @module.add_item({:id => @page.id, :type => 'wiki_page'})
expect(@tag).to be_nil
end
@ -301,7 +301,7 @@ describe ContextModule do
it "should not generate progressions for non-active modules" do
student_in_course :active_all => true
tehmod = @course.context_modules.create! :name => "teh module"
page = @course.wiki.wiki_pages.create! :title => "view this page"
page = @course.wiki_pages.create! :title => "view this page"
tag = tehmod.add_item(:id => page.id, :type => 'wiki_page')
tehmod.completion_requirements = { tag.id => {:type => 'must_view'} }
tehmod.workflow_state = 'active'
@ -323,7 +323,7 @@ describe ContextModule do
it 'should not remove completed contribution requirements when viewed' do
student_in_course(active_all: true)
mod = @course.context_modules.create!(name: 'Module')
page = @course.wiki.wiki_pages.create!(title: 'Edit This Page')
page = @course.wiki_pages.create!(title: 'Edit This Page')
tag = mod.add_item(id: page.id, type: 'wiki_page')
mod.completion_requirements = [{ id: tag.id, type: 'must_contribute' }]
mod.workflow_state = 'active'

View File

@ -24,49 +24,49 @@ describe Context do
course = Course.create!
expect(Context.find_by_asset_string(course.asset_string)).to eql(course)
end
it "should not find an invalid course" do
expect(Context.find_by_asset_string("course_0")).to eql(nil)
end
it "should find a valid group" do
group = Group.create!(:context => Account.default)
expect(Context.find_by_asset_string(group.asset_string)).to eql(group)
end
it "should not find an invalid group" do
expect(Context.find_by_asset_string("group_0")).to eql(nil)
end
it "should find a valid account" do
account = Account.create!(:name => "test")
expect(Context.find_by_asset_string(account.asset_string)).to eql(account)
end
it "should not find an invalid account" do
expect(Context.find_by_asset_string("account_0")).to eql(nil)
end
it "should find a valid user" do
user = User.create!
expect(Context.find_by_asset_string(user.asset_string)).to eql(user)
end
it "should not find an invalid user" do
expect(Context.find_by_asset_string("user_0")).to eql(nil)
end
it "should not find an invalid asset string" do
expect(Context.find_by_asset_string("")).to eql(nil)
expect(Context.find_by_asset_string("loser_5")).to eql(nil)
end
it "should not find a valid asset" do
assignment_model
Context.find_by_asset_string(@assignment.asset_string)
end
end
context "find_asset_by_asset_string" do
it "should find a valid assignment" do
assignment_model
@ -74,13 +74,13 @@ describe Context do
end
it "should find a valid wiki page" do
course_model
page = @course.wiki.wiki_pages.create!(:title => 'test')
page = @course.wiki_pages.create!(:title => 'test')
expect(@course.find_asset(page.asset_string)).to eql(page)
expect(@course.find_asset(page.asset_string, [:wiki_page])).to eql(page)
end
it "should not find a valid wiki page if told to ignore wiki pages" do
course_model
page = @course.wiki.wiki_pages.create!(:title => 'test')
page = @course.wiki_pages.create!(:title => 'test')
expect(@course.find_asset(page.asset_string, [:assignment])).to eql(nil)
end
it "should not find an invalid assignment" do

View File

@ -2096,7 +2096,7 @@ describe Course, "backup" do
group = @course.assignment_groups.create!(:name => "Some Assignment Group")
@course.assignments.create!(:title => "Some Assignment", :assignment_group => group)
@course.calendar_events.create!(:title => "Some Event", :start_at => Time.now, :end_at => Time.now)
@course.wiki.wiki_pages.create!(:title => "Some Page")
@course.wiki_pages.create!(:title => "Some Page")
topic = @course.discussion_topics.create!(:title => "Some Discussion")
topic.discussion_entries.create!(:message => "just a test")
@course

View File

@ -89,9 +89,9 @@ describe Course do
# wiki pages tests
migration_ids = ["1865116206002", "1865116207002"].sort
added_migration_ids = @course.wiki.wiki_pages.map(&:migration_id).uniq.sort
added_migration_ids = @course.wiki_pages.map(&:migration_id).uniq.sort
expect(added_migration_ids).to eq(migration_ids)
expect(@course.wiki.wiki_pages.length).to eq(migration_ids.length)
expect(@course.wiki_pages.length).to eq(migration_ids.length)
# front page
page = @course.wiki.front_page
expect(page).not_to be_nil

View File

@ -29,7 +29,7 @@ describe "Importing wikis" do
Importers::WikiPageImporter.import_from_migration(data, context, migration)
Importers::WikiPageImporter.import_from_migration(data, context, migration)
expect(context.wiki.wiki_pages.count).to eq 1
expect(context.wiki_pages.count).to eq 1
wiki = WikiPage.where(migration_id: data[:migration_id]).first
expect(wiki.title).to eq data[:title]
@ -49,7 +49,7 @@ describe "Importing wikis" do
migration.resolve_content_links!
# The wiki references should resolve to course urls
expect(context.wiki.wiki_pages.count).to eq 18
expect(context.wiki_pages.count).to eq 18
wiki = WikiPage.where(migration_id: 'res00146').first
expect(wiki.body =~ /\/courses\/\d+\/pages\/course-glossary-a-to-d/).not_to be_nil
expect(wiki.body =~ /\/courses\/\d+\/pages\/course-glossary-e-f-g-h/).not_to be_nil
@ -62,7 +62,7 @@ describe "Importing wikis" do
context = get_import_context('bb9')
migration = context.content_migrations.create!
Importers::WikiPageImporter.import_from_migration(data, context, migration)
page = context.wiki.wiki_pages.last
page = context.wiki_pages.last
page.destroy
Importers::WikiPageImporter.import_from_migration(data, context, migration)
expect(page.reload).not_to be_deleted

View File

@ -56,10 +56,10 @@ describe MasterCourses::ChildSubscription do
child_course = course_factory
sub = @template.add_child_course!(@course)
original_page = master_course.wiki.wiki_pages.create!(:title => "blah")
original_page = master_course.wiki_pages.create!(:title => "blah")
mc_tag = @template.create_content_tag_for!(original_page)
page_copy = child_course.wiki.wiki_pages.create!(:title => "blah", :migration_id => mc_tag.migration_id)
page_copy = child_course.wiki_pages.create!(:title => "blah", :migration_id => mc_tag.migration_id)
child_tag = sub.create_content_tag_for!(page_copy)
sub.destroy!

View File

@ -27,7 +27,7 @@ describe MasterCourses::MasterContentTag do
it "should match the generated migration_ids from CCHelper" do
ann = @course.announcements.create!(:message => "blah")
topic = @course.discussion_topics.create!
page = @course.wiki.wiki_pages.create!(:title => "blah")
page = @course.wiki_pages.create!(:title => "blah")
[ann, topic, page].each do |content|
expect(@template.create_content_tag_for!(content).migration_id).to eq @template.migration_id_for(content)

View File

@ -195,12 +195,12 @@ describe MasterCourses::MasterMigration do
expect(cm1.migration_settings[:imported_assets]["DiscussionTopic"]).to eq topic_to.id.to_s
expect(cm1.migration_settings[:imported_assets]["Attachment"]).to eq att_to.id.to_s
page = @copy_from.wiki.wiki_pages.create!(:title => "another title")
page = @copy_from.wiki_pages.create!(:title => "another title")
run_master_migration
expect(@migration.export_results.keys).to eq [:selective]
page_to = @copy_to.wiki.wiki_pages.where(:migration_id => mig_id(page)).first
page_to = @copy_to.wiki_pages.where(:migration_id => mig_id(page)).first
expect(page_to).to be_present
cm2 = ContentMigration.find(@migration.import_results.keys.first)
@ -216,8 +216,8 @@ describe MasterCourses::MasterMigration do
assmt = @copy_from.assignments.create!
topic = @copy_from.discussion_topics.create!(:message => "hi", :title => "discussion title")
ann = @copy_from.announcements.create!(:message => "goodbye")
page = @copy_from.wiki.wiki_pages.create!(:title => "wiki", :body => "ohai")
page2 = @copy_from.wiki.wiki_pages.create!(:title => "wiki", :body => "bluh")
page = @copy_from.wiki_pages.create!(:title => "wiki", :body => "ohai")
page2 = @copy_from.wiki_pages.create!(:title => "wiki", :body => "bluh")
quiz = @copy_from.quizzes.create!
quiz2 = @copy_from.quizzes.create!
bank = @copy_from.assessment_question_banks.create!(:title => 'bank')
@ -232,8 +232,8 @@ describe MasterCourses::MasterMigration do
assmt_to = @copy_to.assignments.where(:migration_id => mig_id(assmt)).first
topic_to = @copy_to.discussion_topics.where(:migration_id => mig_id(topic)).first
ann_to = @copy_to.announcements.where(:migration_id => mig_id(ann)).first
page_to = @copy_to.wiki.wiki_pages.where(:migration_id => mig_id(page)).first
page2_to = @copy_to.wiki.wiki_pages.where(:migration_id => mig_id(page2)).first
page_to = @copy_to.wiki_pages.where(:migration_id => mig_id(page)).first
page2_to = @copy_to.wiki_pages.where(:migration_id => mig_id(page2)).first
quiz_to = @copy_to.quizzes.where(:migration_id => mig_id(quiz)).first
quiz2_to = @copy_to.quizzes.where(:migration_id => mig_id(quiz2)).first
bank_to = @copy_to.assessment_question_banks.where(:migration_id => mig_id(bank)).first
@ -298,7 +298,7 @@ describe MasterCourses::MasterMigration do
Timecop.freeze(10.minutes.from_now) do
assmt.update_attribute(:title, 'new title eh')
page = @copy_from.wiki.wiki_pages.create!(:title => "wiki", :body => "ohai")
page = @copy_from.wiki_pages.create!(:title => "wiki", :body => "ohai")
file = @copy_from.attachments.create!(:filename => 'blah', :uploaded_data => default_uploaded_data)
end
@ -318,7 +318,7 @@ describe MasterCourses::MasterMigration do
run_master_migration
Timecop.travel(10.minutes.from_now) do
3.times { |x| @copy_from.wiki.wiki_pages.create! :title => "Page #{x}" }
3.times { |x| @copy_from.wiki_pages.create! :title => "Page #{x}" }
mm = run_master_migration
expect(mm.export_results[:selective][:created]['WikiPage'].length).to eq 2
end
@ -337,7 +337,7 @@ describe MasterCourses::MasterMigration do
new_title = "new title"
topic_to1.update_attribute(:title, new_title)
page = @copy_from.wiki.wiki_pages.create!(:title => "another title")
page = @copy_from.wiki_pages.create!(:title => "another title")
@copy_to2 = course_factory
@template.add_child_course!(@copy_to2) # new child course - needs full update
@ -345,11 +345,11 @@ describe MasterCourses::MasterMigration do
run_master_migration
expect(@migration.export_results.keys).to match_array([:selective, :full]) # should create both
expect(@copy_to1.wiki.wiki_pages.where(:migration_id => mig_id(page)).first).to be_present # should bring the wiki page in the selective
expect(@copy_to1.wiki_pages.where(:migration_id => mig_id(page)).first).to be_present # should bring the wiki page in the selective
expect(topic_to1.reload.title).to eq new_title # should not have have overwritten the new change in the child course
expect(@copy_to2.discussion_topics.where(:migration_id => mig_id(topic)).first).to be_present # should bring both in the full
expect(@copy_to2.wiki.wiki_pages.where(:migration_id => mig_id(page)).first).to be_present
expect(@copy_to2.wiki_pages.where(:migration_id => mig_id(page)).first).to be_present
end
it "should skip master course restriction validations on import" do
@ -359,7 +359,7 @@ describe MasterCourses::MasterMigration do
assmt = @copy_from.assignments.create!
topic = @copy_from.discussion_topics.create!(:message => "hi", :title => "discussion title")
ann = @copy_from.announcements.create!(:message => "goodbye")
page = @copy_from.wiki.wiki_pages.create!(:title => "wiki", :body => "ohai")
page = @copy_from.wiki_pages.create!(:title => "wiki", :body => "ohai")
quiz = @copy_from.quizzes.create!
qq = quiz.quiz_questions.create!(:question_data => {'question_name' => 'test question', 'question_type' => 'essay_question'})
bank = @copy_from.assessment_question_banks.create!(:title => 'bank')
@ -379,7 +379,7 @@ describe MasterCourses::MasterMigration do
copied_assmt = @copy_to.assignments.where(:migration_id => mig_id(assmt)).first
copied_topic = @copy_to.discussion_topics.where(:migration_id => mig_id(topic)).first
copied_ann = @copy_to.announcements.where(:migration_id => mig_id(ann)).first
copied_page = @copy_to.wiki.wiki_pages.where(:migration_id => mig_id(page)).first
copied_page = @copy_to.wiki_pages.where(:migration_id => mig_id(page)).first
copied_quiz = @copy_to.quizzes.where(:migration_id => mig_id(quiz)).first
copied_qq = copied_quiz.quiz_questions.where(:migration_id => mig_id(qq)).first
copied_bank = @copy_to.assessment_question_banks.where(:migration_id => mig_id(bank)).first
@ -434,13 +434,13 @@ describe MasterCourses::MasterMigration do
# TODO: add more content here as we add the Restrictor module to more models
old_title = "some title"
page = @copy_from.wiki.wiki_pages.create!(:title => old_title, :body => "ohai")
page = @copy_from.wiki_pages.create!(:title => old_title, :body => "ohai")
assignment = @copy_from.assignments.create!(:title => old_title, :description => "kthnx")
run_master_migration
# WikiPage
copied_page = @copy_to.wiki.wiki_pages.where(:migration_id => mig_id(page)).first
copied_page = @copy_to.wiki_pages.where(:migration_id => mig_id(page)).first
child_tag = sub.child_content_tags.polymorphic_where(:content => copied_page).first
expect(child_tag).to be_present # should create a tag
new_child_text = "<p>some other text here</p>"
@ -884,7 +884,7 @@ describe MasterCourses::MasterMigration do
cm = @copy_from.context_modules.create!(:name => "some module")
item = cm.add_item(:id => assmt.id, :type => 'assignment')
att = Attachment.create!(:filename => 'first.txt', :uploaded_data => StringIO.new('ohai'), :folder => Folder.unfiled_folder(@copy_from), :context => @copy_from)
page = @copy_from.wiki.wiki_pages.create!(:title => "wiki", :body => "ohai")
page = @copy_from.wiki_pages.create!(:title => "wiki", :body => "ohai")
quiz = @copy_from.quizzes.create!
allow(TestExternalContentService).to receive(:applies_to_course?).and_return(true)
@ -911,7 +911,7 @@ describe MasterCourses::MasterMigration do
copied_cm = @copy_to.context_modules.where(:migration_id => mig_id(cm)).first
copied_item = @copy_to.context_module_tags.where(:migration_id => mig_id(item)).first
copied_att = @copy_to.attachments.where(:migration_id => mig_id(att)).first
copied_page = @copy_to.wiki.wiki_pages.where(:migration_id => mig_id(page)).first
copied_page = @copy_to.wiki_pages.where(:migration_id => mig_id(page)).first
copied_quiz = @copy_to.quizzes.where(:migration_id => mig_id(quiz)).first
expect(TestExternalContentService.course).to eq @copy_to

View File

@ -123,7 +123,7 @@ describe MasterCourses::MasterTemplate do
expect(@template.content_tag_for(@assignment).id).to eq old_tag_id
# should still create a tag even if it's not found in the index
@page = @course.wiki.wiki_pages.create!(:title => "title")
@page = @course.wiki_pages.create!(:title => "title")
page_tag = @template.content_tag_for(@page)
expect(page_tag.reload.content).to eq @page
end

View File

@ -21,11 +21,11 @@ describe MasterCourses::Restrictor do
before :once do
@copy_from = course_factory
@template = MasterCourses::MasterTemplate.set_as_master_course(@copy_from)
@original_page = @copy_from.wiki.wiki_pages.create!(:title => "blah", :body => "bloo")
@original_page = @copy_from.wiki_pages.create!(:title => "blah", :body => "bloo")
@tag = @template.create_content_tag_for!(@original_page)
@copy_to = course_factory
@page_copy = @copy_to.wiki.wiki_pages.new(:title => "blah", :body => "bloo") # just create a copy directly instead of doing a real migraiton
@page_copy = @copy_to.wiki_pages.new(:title => "blah", :body => "bloo") # just create a copy directly instead of doing a real migraiton
@page_copy.migration_id = @tag.migration_id
@page_copy.save!
@page_copy.child_content_restrictions = nil
@ -111,10 +111,10 @@ describe MasterCourses::Restrictor do
describe "preload_child_restrictions" do
it "should bulk preload restrictions in a single query" do
page2 = @copy_from.wiki.wiki_pages.create!(:title => "blah2")
page2 = @copy_from.wiki_pages.create!(:title => "blah2")
tag2 = @template.create_content_tag_for!(page2, {:restrictions => {:content => true}})
page2_copy = @copy_to.wiki.wiki_pages.new(:title => "blah2") # just create a copy directly instead of doing a real migraiton
page2_copy = @copy_to.wiki_pages.new(:title => "blah2") # just create a copy directly instead of doing a real migraiton
page2_copy.migration_id = tag2.migration_id
page2_copy.save!
@ -128,7 +128,7 @@ describe MasterCourses::Restrictor do
describe "preload_default_template_restrictions" do
it "should bulk preload master-side restrictions in a single query" do
page2 = @copy_from.wiki.wiki_pages.create!(:title => "blah2")
page2 = @copy_from.wiki_pages.create!(:title => "blah2")
tag2 = @template.create_content_tag_for!(page2, {:restrictions => {:content => true}})
# should also work for associated assignments (since they share a master content tag)

View File

@ -24,7 +24,7 @@ describe WikiPage do
course_with_teacher(:active_all => true)
n = Notification.create(:name => "Updated Wiki Page", :category => "TestImmediately")
NotificationPolicy.create(:notification => n, :communication_channel => @user.communication_channel, :frequency => "immediately")
p = @course.wiki.wiki_pages.create(:title => "some page")
p = @course.wiki_pages.create(:title => "some page")
p.created_at = 3.days.ago
p.notify_of_update = true
p.save!
@ -41,7 +41,7 @@ describe WikiPage do
course_with_student(:active_all => true)
n = Notification.create(:name => "Updated Wiki Page", :category => "TestImmediately")
NotificationPolicy.create(:notification => n, :communication_channel => @user.communication_channel, :frequency => "immediately")
p = @course.wiki.wiki_pages.create(:title => "some page")
p = @course.wiki_pages.create(:title => "some page")
p.created_at = 3.days.ago
p.notify_of_update = true
p.save!
@ -54,7 +54,7 @@ describe WikiPage do
n = Notification.create(:name => "Updated Wiki Page", :category => "TestImmediately")
NotificationPolicy.create(:notification => n, :communication_channel => @user.communication_channel, :frequency => "immediately")
@course.update_attributes(:start_at => 2.days.from_now, :restrict_enrollments_to_course_dates => true)
p = @course.wiki.wiki_pages.create(:title => "some page")
p = @course.wiki_pages.create(:title => "some page")
p.created_at = 3.days.ago
p.notify_of_update = true
p.save!
@ -103,16 +103,16 @@ describe WikiPage do
it "should validate the title" do
course_with_teacher(:active_all => true)
expect(@course.wiki.wiki_pages.new(:title => "").valid?).not_to be_truthy
expect(@course.wiki.wiki_pages.new(:title => "!!!").valid?).not_to be_truthy
expect(@course.wiki.wiki_pages.new(:title => "a"*256).valid?).not_to be_truthy
expect(@course.wiki.wiki_pages.new(:title => "asdf").valid?).to be_truthy
expect(@course.wiki_pages.new(:title => "").valid?).not_to be_truthy
expect(@course.wiki_pages.new(:title => "!!!").valid?).not_to be_truthy
expect(@course.wiki_pages.new(:title => "a"*256).valid?).not_to be_truthy
expect(@course.wiki_pages.new(:title => "asdf").valid?).to be_truthy
end
it "should set as front page" do
course_with_teacher(:active_all => true)
new_front_page = @course.wiki.wiki_pages.create!(:title => "asdf")
new_front_page = @course.wiki_pages.create!(:title => "asdf")
expect(new_front_page.set_as_front_page!).to eq true
@course.wiki.reload
@ -127,7 +127,7 @@ describe WikiPage do
front_page.workflow_state = 'unpublished'
expect(front_page.valid?).not_to be_truthy
new_front_page = @course.wiki.wiki_pages.create!(:title => "asdf")
new_front_page = @course.wiki_pages.create!(:title => "asdf")
new_front_page.set_as_front_page!
front_page.reload
@ -152,24 +152,24 @@ describe WikiPage do
it "should transliterate unicode characters in the title for the url" do
course_with_teacher(:active_all => true)
page = @course.wiki.wiki_pages.create!(:title => "æ vęrÿ ßpéçïâł なまえ ¼‽")
page = @course.wiki_pages.create!(:title => "æ vęrÿ ßpéçïâł なまえ ¼‽")
expect(page.url).to eq 'ae-very-sspecial-namae-1-slash-4'
end
it "should make the title/url unique" do
course_with_teacher(:active_all => true)
p1 = @course.wiki.wiki_pages.create(:title => "Asdf")
p2 = @course.wiki.wiki_pages.create(:title => "Asdf")
p1 = @course.wiki_pages.create(:title => "Asdf")
p2 = @course.wiki_pages.create(:title => "Asdf")
expect(p2.title).to eql('Asdf-2')
expect(p2.url).to eql('asdf-2')
end
it "should make the title unique and truncate to proper length" do
course_with_teacher(:active_all => true)
p1 = @course.wiki.wiki_pages.create!(:title => "a" * WikiPage::TITLE_LENGTH)
p2 = @course.wiki.wiki_pages.create!(:title => p1.title)
p3 = @course.wiki.wiki_pages.create!(:title => p1.title)
p4 = @course.wiki.wiki_pages.create!(:title => "a" * (WikiPage::TITLE_LENGTH - 2) + "-2")
p1 = @course.wiki_pages.create!(:title => "a" * WikiPage::TITLE_LENGTH)
p2 = @course.wiki_pages.create!(:title => p1.title)
p3 = @course.wiki_pages.create!(:title => p1.title)
p4 = @course.wiki_pages.create!(:title => "a" * (WikiPage::TITLE_LENGTH - 2) + "-2")
expect(p2.title.length).to eq WikiPage::TITLE_LENGTH
expect(p2.title.end_with?('-2')).to be_truthy
expect(p3.title.length).to eq WikiPage::TITLE_LENGTH
@ -180,11 +180,11 @@ describe WikiPage do
it "should let you reuse the title/url of a deleted page" do
course_with_teacher(:active_all => true)
p1 = @course.wiki.wiki_pages.create(:title => "Asdf")
p1 = @course.wiki_pages.create(:title => "Asdf")
p1.workflow_state = 'deleted'
p1.save
p2 = @course.wiki.wiki_pages.create(:title => "Asdf")
p2 = @course.wiki_pages.create(:title => "Asdf")
p2.reload
expect(p2.title).to eql('Asdf')
expect(p2.url).to eql('asdf')
@ -203,7 +203,7 @@ describe WikiPage do
context "unpublished" do
before :once do
teacher_in_course(:active_all => true)
@page = @course.wiki.wiki_pages.create(:title => "some page")
@page = @course.wiki_pages.create(:title => "some page")
@page.workflow_state = :unpublished
@page.save!
end
@ -229,7 +229,7 @@ describe WikiPage do
describe '#can_edit_page?' do
it 'is true if the user has manage_wiki rights' do
course_with_teacher(:active_all => true)
page = @course.wiki.wiki_pages.create(:title => "some page", :editing_roles => 'teachers')
page = @course.wiki_pages.create(:title => "some page", :editing_roles => 'teachers')
page.workflow_state = 'unpublished'
expect(page.can_edit_page?(@teacher)).to be_truthy
end
@ -243,14 +243,14 @@ describe WikiPage do
end
it 'does not grant teachers or TAs edit rights when editing roles are "Only teachers"' do
page = @course.wiki.wiki_pages.create(:title => "some page", :editing_roles => 'teachers')
page = @course.wiki_pages.create(:title => "some page", :editing_roles => 'teachers')
page.workflow_state = 'unpublished'
expect(page.can_edit_page?(@teacher)).to be_falsey
expect(page.can_edit_page?(@ta)).to be_falsey
end
it 'grants teachers and TAs edit rights when editing roles are "Teachers and students"' do
page = @course.wiki.wiki_pages.create(:title => "some page", :editing_roles => 'teachers,students')
page = @course.wiki_pages.create(:title => "some page", :editing_roles => 'teachers,students')
page.workflow_state = 'unpublished'
expect(page.can_edit_page?(@teacher)).to be_truthy
expect(page.can_edit_page?(@ta)).to be_truthy
@ -259,14 +259,14 @@ describe WikiPage do
it 'is true for students who are in the course' do
course_with_student(:active_all => true)
page = @course.wiki.wiki_pages.create(:title => "some page", :editing_roles => 'students')
page = @course.wiki_pages.create(:title => "some page", :editing_roles => 'students')
student = @course.students.first
expect(page.can_edit_page?(student)).to be_truthy
end
it 'is not true for users who are not in the course (if it is not public)' do
course_factory(active_all: true)
page = @course.wiki.wiki_pages.create(:title => "some page", :editing_roles => 'public')
page = @course.wiki_pages.create(:title => "some page", :editing_roles => 'public')
user_factory(active_all: true)
expect(page.can_edit_page?(@user)).to be_falsey
end
@ -275,7 +275,7 @@ describe WikiPage do
course_factory(active_all: true)
@course.is_public = true
@course.save!
page = @course.wiki.wiki_pages.create(:title => "some page", :editing_roles => 'public')
page = @course.wiki_pages.create(:title => "some page", :editing_roles => 'public')
user_factory(active_all: true)
expect(page.can_edit_page?(@user)).to be_truthy
end
@ -313,7 +313,7 @@ describe WikiPage do
file_url = "/courses/#{some_other_course.id}/files/1"
link_string = "<a href='#{file_url}'>link</a>"
page = course.wiki.wiki_pages.create!(title: 'New', body: "<p>#{link_string}</p>", user: @user)
page = course.wiki_pages.create!(title: 'New', body: "<p>#{link_string}</p>", user: @user)
expect(page.body).to include(file_url)
end
end
@ -341,7 +341,7 @@ describe WikiPage do
context 'admins' do
before :once do
account_admin_user
@page = @course.wiki.wiki_pages.build(:title => 'Some page')
@page = @course.wiki_pages.create!(:title => 'Some page')
@page.workflow_state = 'active'
end
@ -370,7 +370,7 @@ describe WikiPage do
context 'teachers' do
before :once do
course_with_teacher :course => @course, :active_all => true
@page = @course.wiki.wiki_pages.build(:title => 'Some page')
@page = @course.wiki_pages.create!(:title => 'Some page')
@page.workflow_state = 'active'
end
@ -399,7 +399,7 @@ describe WikiPage do
context 'students' do
before :once do
course_with_student :course => @course, :active_all => true
@page = @course.wiki.wiki_pages.build(:title => 'Some page')
@page = @course.wiki_pages.create!(:title => 'Some page')
@page.workflow_state = 'active'
end
@ -459,6 +459,7 @@ describe WikiPage do
before :once do
@page.context.default_wiki_editing_roles = 'teachers,students'
@page.context.save!
@page.reload
end
it 'should be given create rights' do
@ -545,7 +546,7 @@ describe WikiPage do
end
it "should destroy its content tags" do
@page = @course.wiki.wiki_pages.create! title: 'destroy me'
@page = @course.wiki_pages.create! title: 'destroy me'
@module = @course.context_modules.create!(:name => "module")
tag = @module.add_item(type: 'WikiPage', title: 'kill meeee', id: @page.id)
@page.destroy
@ -558,7 +559,7 @@ describe WikiPage do
before (:once) { course_factory }
it "should restore to unpublished state" do
@page = @course.wiki.wiki_pages.create! title: 'dot dot dot'
@page = @course.wiki_pages.create! title: 'dot dot dot'
@page.update_attribute(:workflow_state, 'deleted')
@page.restore
expect(@page.reload).to be_unpublished
@ -583,7 +584,7 @@ describe WikiPage do
end
it "should not restore its content tags" do
@page = @course.wiki.wiki_pages.create! title: 'dot dot dot'
@page = @course.wiki_pages.create! title: 'dot dot dot'
@module = @course.context_modules.create!(:name => "module")
tag = @module.add_item(type: 'WikiPage', title: 'dash dash dash', id: @page.id)
@page.update_attribute(:workflow_state, 'deleted')
@ -596,7 +597,7 @@ describe WikiPage do
describe "context_module_action" do
it "should process all content tags" do
course_with_student active_all: true
page = @course.wiki.wiki_pages.create! title: 'teh page'
page = @course.wiki_pages.create! title: 'teh page'
mod1 = @course.context_modules.create name: 'module1'
tag1 = mod1.add_item type: 'wiki_page', id: page.id
mod1.completion_requirements = { tag1.id => { type: 'must_view' } }
@ -614,8 +615,8 @@ describe WikiPage do
describe "locked_for?" do
it "should lock by preceding item and sequential progress" do
course_with_student active_all: true
pageB = @course.wiki.wiki_pages.create! title: 'B'
pageC = @course.wiki.wiki_pages.create! title: 'C'
pageB = @course.wiki_pages.create! title: 'B'
pageC = @course.wiki_pages.create! title: 'C'
mod = @course.context_modules.create name: 'teh module'
tagB = mod.add_item type: 'wiki_page', id: pageB.id
tagC = mod.add_item type: 'wiki_page', id: pageC.id
@ -627,7 +628,7 @@ describe WikiPage do
it "includes a future unlock date" do
course_with_student active_all: true
page = @course.wiki.wiki_pages.create! title: 'page'
page = @course.wiki_pages.create! title: 'page'
mod = @course.context_modules.create name: 'teh module', unlock_at: 1.week.from_now
mod.add_item type: 'wiki_page', id: page.id
mod.workflow_state = 'unpublished'
@ -637,7 +638,7 @@ describe WikiPage do
it "doesn't reference an expired unlock-at date" do
course_with_student active_all: true
page = @course.wiki.wiki_pages.create! title: 'page'
page = @course.wiki_pages.create! title: 'page'
mod = @course.context_modules.create name: 'teh module', unlock_at: 1.week.ago
mod.add_item type: 'wiki_page', id: page.id
mod.workflow_state = 'unpublished'
@ -650,7 +651,7 @@ describe WikiPage do
before(:once) do
Timecop.freeze(1.hour.ago) do
course_factory
@page = @course.wiki.wiki_pages.create! title: 'page'
@page = @course.wiki_pages.create! title: 'page'
@old_timestamp = @page.revised_at
end
end

View File

@ -24,14 +24,14 @@ describe WikiPages::ScopedToUser do
student_in_course(active_all: true, user_name: "some user")
end
let_once(:published) do
@course.wiki.wiki_pages.create({
@course.wiki_pages.create({
title: 'published page',
workflow_state: 'published'
})
end
let_once(:unpublished) do
@course.wiki.wiki_pages.create({
@course.wiki_pages.create({
title: 'unpublished page'
}).tap do |page|
page.unpublish
@ -44,7 +44,7 @@ describe WikiPages::ScopedToUser do
expect(@course.grants_right?(@teacher, :view_unpublished_items)).to be_truthy, 'precondition'
expect(unpublished.workflow_state).to eq('unpublished'), 'precondition'
expect(published.workflow_state).to eq('active'), 'precondition'
scope = @course.wiki.wiki_pages.select(WikiPage.column_names - ['body']).preload(:user)
scope = @course.wiki_pages.select(WikiPage.column_names - ['body']).preload(:user)
scope_filter = WikiPages::ScopedToUser.new(@course, @teacher, scope)
expect(scope_filter.scope).to include(unpublished, published)
end
@ -53,7 +53,7 @@ describe WikiPages::ScopedToUser do
expect(@course.grants_right?(@student, :view_unpublished_items)).to be_falsey, 'precondition'
expect(unpublished.workflow_state).to eq('unpublished'), 'precondition'
expect(published.workflow_state).to eq('active'), 'precondition'
scope = @course.wiki.wiki_pages.select(WikiPage.column_names - ['body']).preload(:user)
scope = @course.wiki_pages.select(WikiPage.column_names - ['body']).preload(:user)
scope_filter = WikiPages::ScopedToUser.new(@course, @student, scope)
expect(scope_filter.scope).not_to include(unpublished)
expect(scope_filter.scope).to include(published)

View File

@ -25,7 +25,7 @@ describe MarkDonePresenter do
end
let(:the_module) { @course.context_modules.create(:name => "mark_as_done_module") }
let(:wiki_page) { @course.wiki.wiki_pages.create(:title => "mark_as_done page", :body => "") }
let(:wiki_page) { @course.wiki_pages.create(:title => "mark_as_done page", :body => "") }
def add_wiki_page_to_module
the_module.add_item(:id => wiki_page.id, :type => 'wiki_page')

View File

@ -287,7 +287,7 @@ describe "student planner" do
end
it "shows and navigates to wiki pages with todo dates from student planner", priority: "1", test_id: 3259304 do
page = @course.wiki.wiki_pages.create!(title: 'Page1', todo_date: Time.zone.now + 2.days)
page = @course.wiki_pages.create!(title: 'Page1', todo_date: Time.zone.now + 2.days)
go_to_list_view
validate_object_displayed('Page')
validate_link_to_url(page, 'pages')
@ -338,7 +338,7 @@ describe "student planner" do
quiz.due_at = Time.zone.now + 2.days
quiz.save!
Array.new(12){|n|n}.each do |i|
@course.wiki.wiki_pages.create!(title: "Page#{i}", todo_date: Time.zone.now + (i-4).days)
@course.wiki_pages.create!(title: "Page#{i}", todo_date: Time.zone.now + (i-4).days)
@course.assignments.create!(name: "assignment#{i}",
due_at: Time.zone.now.advance(days:(i-4)))
@course.discussion_topics.create!(user: @teacher, title: "topic#{i}",

View File

@ -67,7 +67,7 @@ describe 'Canvadoc' do
turn_on_plugin_settings
f('.save_button').click
course_with_teacher_logged_in :account => @account, :active_all => true
@course.wiki.wiki_pages.create!(title: 'Page1')
@course.wiki_pages.create!(title: 'Page1')
file = @course.attachments.create!(display_name: 'some test file', uploaded_data: default_uploaded_data)
file.context = @course
file.save!

View File

@ -39,7 +39,7 @@ describe "context modules" do
@quiz = @course.quizzes.create!(:title => "score 10")
@quiz.publish!
@quiz_tag = @module1.add_item(:id => @quiz.id, :type => 'quiz')
@wiki_page = @course.wiki.wiki_pages.create!(:title => 'title', :body => '')
@wiki_page = @course.wiki_pages.create!(:title => 'title', :body => '')
@wiki_page.workflow_state = 'active'
@wiki_page.save!
@wiki_page_tag = @module1.add_item(:id => @wiki_page.id, :type => 'wiki_page')

View File

@ -290,7 +290,7 @@ describe "context modules" do
end
it "should show student progress once wiki page-view requirement is met", priority: "1", test_id: 126700 do
@wiki_page = @course.wiki.wiki_pages.create!(title: 'Wiki Page')
@wiki_page = @course.wiki_pages.create!(title: 'Wiki Page')
tag = @module1.add_item(id: @wiki_page.id, type: 'wiki_page')
add_requirement({tag.id => {type: 'must_view'}})
wait_for_ajaximations
@ -299,7 +299,7 @@ describe "context modules" do
end
it "should show student progress once wiki page-contribute requirement is met", priority: "1", test_id: 126699 do
@wiki_page = @course.wiki.wiki_pages.create(title: "Wiki_page", editing_roles: "public", notify_of_update: true)
@wiki_page = @course.wiki_pages.create(title: "Wiki_page", editing_roles: "public", notify_of_update: true)
tag = @module1.add_item(id: @wiki_page.id, type: 'wiki_page')
add_requirement({tag.id => {type: 'must_contribute'}})
get "/courses/#{@course.id}/pages/#{@wiki_page.title}/edit"

View File

@ -34,7 +34,7 @@ describe "context modules" do
end
it 'should add an unpublished page to a module', priority: "1", test_id: 126709 do
@unpub_page = @course.wiki.wiki_pages.create!(title: 'Unpublished Page')
@unpub_page = @course.wiki_pages.create!(title: 'Unpublished Page')
@unpub_page.workflow_state = 'unpublished'
@unpub_page.save!
@mod.add_item(type: 'wiki_page', id: @unpub_page.id)
@ -44,7 +44,7 @@ describe "context modules" do
end
it 'should add a published page to a module', priority: "1", test_id: 126710 do
@pub_page = @course.wiki.wiki_pages.create!(title: 'Published Page')
@pub_page = @course.wiki_pages.create!(title: 'Published Page')
@mod.add_item(type: 'wiki_page', id: @pub_page.id)
go_to_modules
verify_module_title('Published Page')
@ -214,7 +214,7 @@ describe "context modules" do
end
it 'edit content page module item inline', priority: "2", test_id: 132491 do
@edit_page = @course.wiki.wiki_pages.create!(title: 'EditMe Page')
@edit_page = @course.wiki_pages.create!(title: 'EditMe Page')
@mod.add_item(type: 'wiki_page', id: @edit_page.id)
go_to_modules
verify_edit_item_form

View File

@ -296,7 +296,7 @@ describe "context modules" do
@assignment3 = @course.assignments.create!(:title => 'last item in module')
@quiz = @course.quizzes.create!(:title => 'quiz assignment')
@quiz.publish!
@wiki = @course.wiki.wiki_pages.create!(:title => "wiki", :body => 'hi')
@wiki = @course.wiki_pages.create!(:title => "wiki", :body => 'hi')
@discussion = @course.discussion_topics.create!(:title => 'discussion')
#add items to module
@ -414,7 +414,7 @@ describe "context modules" do
context 'mark as done' do
def setup
@mark_done_module = create_context_module('Mark Done Module')
page = @course.wiki.wiki_pages.create!(:title => "The page", :body => 'hi')
page = @course.wiki_pages.create!(:title => "The page", :body => 'hi')
@tag = @mark_done_module.add_item({:id => page.id, :type => 'wiki_page'})
@mark_done_module.completion_requirements = {@tag.id => {:type => 'must_mark_done'}}
@mark_done_module.save!
@ -446,7 +446,7 @@ describe "context modules" do
it "should still show the mark done button when navigating directly" do
mod = create_context_module('Mark Done Module')
page = @course.wiki.wiki_pages.create!(:title => "page", :body => 'hi')
page = @course.wiki_pages.create!(:title => "page", :body => 'hi')
assmt = @course.assignments.create!(:title => "assmt")
tag1 = mod.add_item({:id => page.id, :type => 'wiki_page'})
@ -749,7 +749,7 @@ describe "context modules" do
end
it "should not lock a page module item on first load" do
page = @course.wiki.wiki_pages.create!(title: "some page", body: "some body")
page = @course.wiki_pages.create!(title: "some page", body: "some body")
page.set_as_front_page!
tag = @module.add_item({id: page.id, type: 'wiki_page'})

View File

@ -315,10 +315,10 @@ describe "context modules" do
it "should not create a duplicate page if you publish after renaming" do
mod = @course.context_modules.create! name: 'TestModule'
page = @course.wiki.wiki_pages.create title: 'A Page'
page = @course.wiki_pages.create title: 'A Page'
page.workflow_state = 'unpublished'
page.save!
page_count = @course.wiki.wiki_pages.count
page_count = @course.wiki_pages.count
tag = mod.add_item({:id => page.id, :type => 'wiki_page'})
get "/courses/#{@course.id}/modules"
@ -332,7 +332,7 @@ describe "context modules" do
item.find_element(:css, '.publish-icon').click
wait_for_ajax_requests
expect(@course.wiki.wiki_pages.count).to eq page_count
expect(@course.wiki_pages.count).to eq page_count
expect(page.reload).to be_published
end

View File

@ -33,7 +33,7 @@ describe "course copy" do
@course.syllabus_body = "<p>haha</p>"
@course.tab_configuration = [{"id" => 0}, {"id" => 14}, {"id" => 8}, {"id" => 5}, {"id" => 6}, {"id" => 2}, {"id" => 3, "hidden" => true}]
@course.default_view = 'modules'
@course.wiki.wiki_pages.create!(:title => "hi", :body => "Whatever")
@course.wiki_pages.create!(:title => "hi", :body => "Whatever")
@course.save!
get "/courses/#{@course.id}/copy"
@ -45,7 +45,7 @@ describe "course copy" do
expect(@new_course.syllabus_body).to eq @course.syllabus_body
expect(@new_course.tab_configuration).to eq @course.tab_configuration
expect(@new_course.default_view).to eq @course.default_view
expect(@new_course.wiki.wiki_pages.count).to eq 1
expect(@new_course.wiki_pages.count).to eq 1
end
# TODO reimplement per CNVS-29604, but make sure we're testing at the right level

View File

@ -385,7 +385,7 @@ describe "course settings" do
topic = @course.discussion_topics.create!(:title => "discussion title", :message => html)
mod = @course.context_modules.create!(:name => "some module")
tag = mod.add_item(:type => 'external_url', :url => bad_url, :title => 'pls view')
page = @course.wiki.wiki_pages.create!(:title => "wiki", :body => html)
page = @course.wiki_pages.create!(:title => "wiki", :body => html)
quiz = @course.quizzes.create!(:title => 'quiz1', :description => html)
qq = quiz.quiz_questions.create!(:question_data => aq.question_data.merge('question_name' => 'other test question'))
@ -436,7 +436,7 @@ describe "course settings" do
<a href='#{deleted_link}'>link</a>
}
@course.save!
page = @course.wiki.wiki_pages.create!(:title => "wikiii", :body => %{<a href='#{unpublished_link}'>link</a>})
page = @course.wiki_pages.create!(:title => "wikiii", :body => %{<a href='#{unpublished_link}'>link</a>})
get "/courses/#{@course.id}/link_validator"
wait_for_ajaximations

View File

@ -537,7 +537,7 @@ describe "courses" do
@course.show_announcements_on_home_page = true
@course.home_page_announcement_limit = 5
@course.save!
@course.wiki.wiki_pages.create!(:title => 'blah').set_as_front_page!
@course.wiki_pages.create!(:title => 'blah').set_as_front_page!
get "/courses/#{@course.id}"

View File

@ -24,7 +24,7 @@ describe "enhanceable_content" do
stub_kaltura
course_with_teacher_logged_in
page = @course.wiki.wiki_pages.build(:title => 'title')
page = @course.wiki_pages.build(:title => 'title')
page.body = %{
<div id="dialog_for_link1" class="enhanceable_content dialog">dialog for link 1</div>
<a href="#dialog_for_link1" id="link1">link 1</a>
@ -99,7 +99,7 @@ describe "enhanceable_content" do
course_factory(active_all: true)
@attachment = @course.attachments.create!(:uploaded_data => stub_file_data('video1.mp4', nil, 'video/mp4'))
@page = @course.wiki.wiki_pages.build(:title => 'title')
@page = @course.wiki_pages.build(:title => 'title')
@page.body = %{
<a id="media_comment_0_deadbeef" class="instructure_file_link instructure_video_link" title="Video.mp4"
href="/courses/#{@course.id}/files/#{@attachment.id}/download?wrap=1">Video</a>

View File

@ -256,7 +256,7 @@ describe "groups" do
end
it "should allow all group members to access a page", priority: "1", test_id: 273612 do
@page = @testgroup.first.wiki.wiki_pages.create!(title: "Page", user: @teacher)
@page = @testgroup.first.wiki_pages.create!(title: "Page", user: @teacher)
# Verifying with a few different group members should be enough to ensure all group members can see it
verify_member_sees_group_page

View File

@ -173,13 +173,13 @@ describe "groups" do
end
it "should allow teachers to access a page", priority: "1", test_id: 289992 do
@page = @testgroup.first.wiki.wiki_pages.create!(title: "Page", user: @students.first)
@page = @testgroup.first.wiki_pages.create!(title: "Page", user: @students.first)
# Verifies teacher can access the group page & that it's the correct page
verify_member_sees_group_page
end
it "has unique pages in the cloned groups", priority: "2", test_id: 1041949 do
@page = @testgroup.first.wiki.wiki_pages.create!(title: "Page", user: @students.first)
@page = @testgroup.first.wiki_pages.create!(title: "Page", user: @students.first)
get pages_page
expect(f('.index-content')).to contain_css('.wiki-page-link')

View File

@ -80,16 +80,16 @@ module BlueprintCourseCommon
def create_and_migrate_master_pages(master)
template = master.master_course_templates.first
@page1 = master.wiki.wiki_pages.create!(title: "Page 1", body: "Wiki Page 1")
@page1 = master.wiki_pages.create!(title: "Page 1", body: "Wiki Page 1")
template.create_content_tag_for!(@page1)
@page2 = master.wiki.wiki_pages.create!(title: "Page 2", body: "Wiki Page 2")
@page2 = master.wiki_pages.create!(title: "Page 2", body: "Wiki Page 2")
tag1 = template.create_content_tag_for!(@page2)
tag1.update(restrictions: {content: true})
run_master_course_migration(master)
end
def update_child_page(minion)
child_page = minion.wiki.wiki_pages.where(title: @page1.title).first
child_page = minion.wiki_pages.where(title: @page1.title).first
child_page.update(body: "Child Wiki Page updated")
end

View File

@ -131,17 +131,17 @@ shared_examples 'pages_page' do |context|
include SharedExamplesCommon
it "should load pages index and display all pages", priority: pick_priority(context, student: "1", teacher: "2"), test_id: pick_test_id(context, student: 273610, teacher: 324927) do
@testgroup.first.wiki.wiki_pages.create!(title: "Page 1", user: @teacher)
@testgroup.first.wiki.wiki_pages.create!(title: "Page 2", user: @teacher)
@testgroup.first.wiki_pages.create!(title: "Page 1", user: @teacher)
@testgroup.first.wiki_pages.create!(title: "Page 2", user: @teacher)
get pages_page
expect(ff('.collectionViewItems .clickable').size).to eq 2
end
it "should only list in-group pages in the content right pane", priority: pick_priority(context, student: "1", teacher: "2"), test_id: pick_test_id(context, student: 273620, teacher: 324928) do
# create group and course announcements
group_page = @testgroup.first.wiki.wiki_pages.create!(user: @teacher,
group_page = @testgroup.first.wiki_pages.create!(user: @teacher,
title: 'Group Page')
course_page = @course.wiki.wiki_pages.create!(user: @teacher,
course_page = @course.wiki_pages.create!(user: @teacher,
title: 'Course Page')
get pages_page

View File

@ -101,7 +101,7 @@ module WikiAndTinyCommon
end
def create_wiki_page(title, unpublished, edit_roles)
wiki_page = @course.wiki.wiki_pages.create(:title => title, :editing_roles => edit_roles, :notify_of_update => true)
wiki_page = @course.wiki_pages.create(:title => title, :editing_roles => edit_roles, :notify_of_update => true)
wiki_page.unpublish! if unpublished
wiki_page
end

Some files were not shown because too many files have changed in this diff Show More