Browse files

Cleanup

  • Loading branch information...
1 parent 353fe86 commit 9257fe3c93bb1f842246b64de8b0a78efaaa2a41 @halogenandtoast halogenandtoast committed Sep 23, 2011
Showing with 16 additions and 6 deletions.
  1. +1 −1 spec/driver_spec.rb
  2. +13 −5 src/UnsupportedContentHandler.cpp
  3. +2 −0 src/UnsupportedContentHandler.h
View
2 spec/driver_spec.rb
@@ -142,7 +142,7 @@
end
end
- it "should render unsupported content types gracefully" do
+ it "renders unsupported content types gracefully" do
subject.visit("/")
subject.body.should =~ /css/
end
View
18 src/UnsupportedContentHandler.cpp
@@ -12,12 +12,20 @@ UnsupportedContentHandler::UnsupportedContentHandler(WebPage *page, QNetworkRepl
void UnsupportedContentHandler::handleUnsupportedContent() {
QVariant contentMimeType = m_reply->header(QNetworkRequest::ContentTypeHeader);
if(!contentMimeType.isNull()) {
@jferris
thoughtbot, inc. member
jferris added a note Sep 23, 2011

Can you reverse the if clause so that we don't need an "if not then else?"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ this->loadUnsupportedContent();
+ this->finish(true);
+ } else {
+ this->finish(false);
+ }
+ this->deleteLater();
+}
+
+void UnsupportedContentHandler::loadUnsupportedContent() {
QByteArray text = m_reply->readAll();
m_page->mainFrame()->setContent(text, QString("text/plain"), m_reply->url());
+}
+
+void UnsupportedContentHandler::finish(bool success) {
connect(m_page, SIGNAL(loadFinished(bool)), m_page, SLOT(loadFinished(bool)));
- m_page->loadFinished(true);
- } else {
- connect(m_page, SIGNAL(loadFinished(bool)), m_page, SLOT(loadFinished(bool)));
- m_page->loadFinished(false);
- }
+ m_page->loadFinished(success);
}
View
2 src/UnsupportedContentHandler.h
@@ -13,4 +13,6 @@ class UnsupportedContentHandler : public QObject {
private:
WebPage *m_page;
QNetworkReply *m_reply;
+ void loadUnsupportedContent();
+ void finish(bool success);
};

0 comments on commit 9257fe3

Please sign in to comment.