can mention in new composer

This commit is contained in:
Dennis Collinson 2012-04-11 17:00:57 -07:00
parent 400bfd19d8
commit 20da08408f
5 changed files with 41 additions and 33 deletions

View file

@ -11,19 +11,7 @@ app.forms.Post = app.views.Base.extend({
}, },
postRenderTemplate : function() { postRenderTemplate : function() {
//this.prepAndBindMentions()
},
prepAndBindMentions : function(){
Mentions.initialize(this.$("textarea.text")); Mentions.initialize(this.$("textarea.text"));
Mentions.fetchContacts(); Mentions.fetchContacts(); //mentions should use app.currentUser
this.$("textarea.text").bind("textchange", $.proxy(this.updateTextWithMarkup, this))
},
updateTextWithMarkup : function() {
this.$("form textarea.text").mentionsInput('val', function(markup){
$('#text_with_markup').val(markup);
});
} }
}); });

View file

@ -11,8 +11,7 @@ app.pages.Composer = app.views.Base.extend({
}, },
formAttrs : { formAttrs : {
// "textarea#text_with_markup" : "text", //fix mentions "textarea#text_with_markup" : "text",
"textarea.text" : "text",
"input.aspect_ids" : "aspect_ids", "input.aspect_ids" : "aspect_ids",
"input.service:checked" : "services" "input.service:checked" : "services"
}, },
@ -25,8 +24,13 @@ app.pages.Composer = app.views.Base.extend({
}, },
navigateNext : function(){ navigateNext : function(){
this.setModelAttributes(); this.$("form textarea.text").mentionsInput('val',
app.router.navigate("framer", true); _.bind(function(markup){
$('#text_with_markup').val(markup);
this.setModelAttributes();
app.router.navigate("framer", true);
}, this)
);
}, },
setModelAttributes : function(evt){ setModelAttributes : function(evt){
@ -57,7 +61,7 @@ app.views.ComposerControls = app.views.Base.extend({
subviews : { subviews : {
".aspect-selector" : "aspectsDropdown", ".aspect-selector" : "aspectsDropdown",
".service-selector" : "servicesSelector", ".service-selector" : "servicesSelector"
}, },
initialize : function() { initialize : function() {

View file

@ -1,6 +1,21 @@
def fill_in_autocomplete(selector, value) def mention_alice(user_name)
pending #make me work if yr board, investigate send_keys #find(selector).native.send_keys(value)
page.execute_script %Q{$('#{selector}').val('#{value}').keyup()} page.execute_script <<-JAVASCRIPT
var mentionsInput = $("textarea.text")
triggerKeypress(64) //@
triggerKeypress(97) //a
mentionsInput.trigger("input") //bring up c
function triggerKeypress(keyCode){
var e = new $.Event("keypress")
e.which = keyCode //@
mentionsInput.trigger(e)
}
JAVASCRIPT
page.find(".mentions-autocomplete-list li:contains('Alice Smith')").click()
sleep(1)
end end
def aspects_dropdown def aspects_dropdown
@ -62,9 +77,7 @@ When /^I write "([^"]*)"(?:| with body "([^"]*)")$/ do |headline, body|
end end
Then /I mention "([^"]*)"$/ do |text| Then /I mention "([^"]*)"$/ do |text|
fill_in_autocomplete('textarea.text', '@a') mention_alice('@a')
sleep(5)
find("li.active").click
end end
When /^I select "([^"]*)" in my aspects dropdown$/ do |title| When /^I select "([^"]*)" in my aspects dropdown$/ do |title|
@ -135,6 +148,6 @@ When /^the frame's body should be "([^"]*)"$/ do |body_text|
find("section.body").text.should == body_text find("section.body").text.should == body_text
end end
Then /^the first post should mention "([^"]*)"$/ do |user_name| Then /^the post should mention "([^"]*)"$/ do |user_name|
pending within('#post-content') { find("a:contains('#{user_name}')").should be_present }
end end

View file

@ -23,14 +23,14 @@ Feature: Creating a new post
Then I should see "This is super skrunkle" as the first post in my stream Then I should see "This is super skrunkle" as the first post in my stream
Then "This is super skrunkle" should be a limited post in my stream Then "This is super skrunkle" should be a limited post in my stream
@wip
Scenario: Mention a contact Scenario: Mention a contact
Given a user named "Alice Smith" with email "alice@alice.alice" Given a user named "Alice Smith" with email "alice@alice.alice"
And a user with email "bob@bob.bob" is connected with "alice@alice.alice" And a user with email "bob@bob.bob" is connected with "alice@alice.alice"
And I mention "alice@alice.alice" And I trumpet
And I wait for the ajax to finish
And I mention "Alice Smith"
And I go through the default composer And I go through the default composer
And I go to "/stream" Then the post should mention "Alice Smith"
Then the first post should mention "Alice Smith"
Scenario: Uploading multiple photos Scenario: Uploading multiple photos
When I write "check out these pictures" When I write "check out these pictures"

View file

@ -46,9 +46,12 @@ describe("app.pages.Composer", function(){
it("instantiates a post on form submit", function(){ it("instantiates a post on form submit", function(){
this.page.$("button.next").click() this.page.$("button.next").click()
expect(this.page.model.get("text")).toBe("Oh My") waitsFor(function(){ return this.page.$("#text_with_markup").text() == "Oh My" })
expect(this.page.model.get("aspect_ids")).toBe("public") runs(function(){
expect(this.page.model.get("services").length).toBe(2) expect(this.page.model.get("aspect_ids")).toBe("public")
expect(this.page.model.get("services").length).toBe(2)
expect(this.page.model.get("text")).toBe("Oh My"))
})
}) })
}); });
}) })