Module: Impostor::Wwf79::Topic

Defined in:
lib/impostor/wwf79.rb

Instance Method Summary collapse

Instance Method Details

#get_new_topic_form(page) ⇒ Object

Get the the new topic form on the page



135
136
137
138
139
# File 'lib/impostor/wwf79.rb', line 135

def get_new_topic_form(page)
  form = page.form('frmAddMessage')
  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



126
127
128
129
130
# File 'lib/impostor/wwf79.rb', line 126

def get_new_topic_uri(forum, subject, message)
  uri = URI.join(self.config.app_root, self.config.config(:post_message_page))
  uri.query = "FID=#{forum}"
  uri
end

#get_topic_from_result(page) ⇒ Object

Get the new topic identifier from the result page



173
174
175
176
177
178
179
180
181
# File 'lib/impostor/wwf79.rb', line 173

def get_topic_from_result(page)
  begin
    tid = page.form('frmAddMessage')['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:



117
118
119
120
# File 'lib/impostor/wwf79.rb', line 117

def new_topic(forum, subject, message) # :nodoc:
  Impostor.not_tested("Impostor::Wwf79::Topic", "new_topic")
  super
end

#set_subject_and_message(form, subject, message) ⇒ Object

Set the subject and message on the new topic form



144
145
146
147
148
# File 'lib/impostor/wwf79.rb', line 144

def set_subject_and_message(form, subject, message)
  form.subject = subject
  form.message = message
  form
end

#validate_new_topic_result(page) ⇒ Object

validate the result of posting the message form FIXME this validation is copied into post module as well



154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# File 'lib/impostor/wwf79.rb', line 154

def validate_new_topic_result(page)
  error = page.body =~ /Message Not Posted/
  if error

    # throttled
    throttled = "You have exceeded the number of posts permitted in the time span"
    too_many = page.body =~ /#{throttled}/
    raise Impostor::ThrottledError.new(throttled) if too_many

    # general error
    raise Impostor::TopicError.new("There was an error making the post")
  end

  page
end