diff options
author | Azul <azul@leap.se> | 2014-07-12 09:12:48 +0200 |
---|---|---|
committer | Azul <azul@leap.se> | 2014-07-17 12:47:47 +0200 |
commit | b17387a17669bfc9afce7435653cd8c29c686999 (patch) | |
tree | 70410bf1df84d88a2c400c7e5c2a78e4550d0126 /features/step_definitions/messages_steps.rb | |
parent | ade74d8a9091ae607586d7b287a0579a2ee7af8e (diff) |
some cleanup of the messages api and cuke feature
Diffstat (limited to 'features/step_definitions/messages_steps.rb')
-rw-r--r-- | features/step_definitions/messages_steps.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/features/step_definitions/messages_steps.rb b/features/step_definitions/messages_steps.rb new file mode 100644 index 0000000..30bc7c3 --- /dev/null +++ b/features/step_definitions/messages_steps.rb @@ -0,0 +1,32 @@ +Given /^there is a message for me$/ do + @message = FactoryGirl.create :message, user_ids_to_show: [@user.id] +end + +Given /^there is a message for me with:$/ do |options| + attributes = options.rows_hash + attributes.merge! user_ids_to_show: [@user.id] + if old_message = Message.find(attributes['id']) + old_message.destroy + end + @message = FactoryGirl.create :message, attributes +end + +Given(/^that message is marked as read$/) do + @message.mark_as_read_by(@user) + @message.save +end + +Then /^the response should (not)?\s?include that message$/ do |negative| + json = JSON.parse(last_response.body) + message = json.detect{|message| message['id'] == @message.id} + if negative.present? + assert !message + else + assert_equal @message.text, message['text'] + end +end + +Then /^that message should be marked as read$/ do + assert @message.reload.read_by? @user + assert !@message.unread_by?(@user) +end |