Module: Impostor::Wwf80::Topic
- Defined in:
- lib/impostor/wwf80.rb
Instance Method Summary collapse
-
#get_new_topic_form(page) ⇒ Object
Get the the new topic form on the page.
-
#get_new_topic_uri(forum, subject, message) ⇒ Object
return a uri used to fetch the new topic page based on the forum, subject, and message.
-
#get_topic_from_result(page) ⇒ Object
Get the new topic identifier from the result page.
-
#new_topic(forum, subject, message) ⇒ Object
:nodoc:.
-
#set_subject_and_message(form, subject, message) ⇒ Object
Set the subject and message on the new topic form.
-
#validate_new_topic_result(page) ⇒ Object
Validate the result of posting the new topic FIXME this validation is copied into post module as well.
Instance Method Details
#get_new_topic_form(page) ⇒ Object
Get the the new topic form on the page
134 135 136 137 138 |
# File 'lib/impostor/wwf80.rb', line 134 def get_new_topic_form(page) form = page.form('frmMessageForm') raise Impostor::TopicError.new("unknown new topic page format") unless form form end |
#get_new_topic_uri(forum, subject, message) ⇒ Object
return a uri used to fetch the new topic page based on the forum, subject, and message
125 126 127 128 129 |
# File 'lib/impostor/wwf80.rb', line 125 def get_new_topic_uri(forum, subject, ) uri = URI.join(self.config.app_root, self.config.config(:new_topic_page)) uri.query = "FID=#{forum}" uri end |
#get_topic_from_result(page) ⇒ Object
Get the new topic identifier from the result page
177 178 179 180 181 182 183 184 185 |
# File 'lib/impostor/wwf80.rb', line 177 def get_topic_from_result(page) begin tid = page.form('frmMessageForm')['TID'].to_i raise StandardError.new("new topic id not found") if tid.zero? tid rescue StandardError => err raise Impostor::TopicError.new(err) end end |
#new_topic(forum, subject, message) ⇒ Object
:nodoc:
116 117 118 119 |
# File 'lib/impostor/wwf80.rb', line 116 def new_topic(forum, subject, ) # :nodoc: Impostor.not_tested("Impostor::Wwf80::Topic", "new_topic") super end |
#set_subject_and_message(form, subject, message) ⇒ Object
Set the subject and message on the new topic form
143 144 145 146 147 |
# File 'lib/impostor/wwf80.rb', line 143 def (form, subject, ) form.subject = subject form. = form end |
#validate_new_topic_result(page) ⇒ Object
Validate the result of posting the new topic FIXME this validation is copied into post module as well
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/impostor/wwf80.rb', line 153 def validate_new_topic_result(page) error = page.search("//table[@class='errorTable']") if error msgs = error.search("//td") # throttled too_many = (msgs.last.text =~ /You have exceeded the number of posts permitted in the time span/ rescue false) raise ThrottledError.new(msgs.last.text.gsub(/\s+/m,' ').strip) if too_many # general error had_error = (error.last.text =~ /Error: Message Not Posted/ rescue false) raise TopicError.new(error.last.text.gsub(/\s+/m,' ').strip) if had_error end page end |