posts_steps.rb 2.65 KB
Newer Older
1 2
# frozen_string_literal: true

3
Then /^the post should be collapsed$/ do
4
  first_post_collapsed?
5 6 7
end

Then /^the post should be expanded$/ do
8
  first_post_expanded?
9 10
end

11 12 13 14
Given /^I have a limited post with text "([^\"]*)" in the aspect "([^"]*)"$/ do |text, aspect_name|
  @me.post :status_message, text: text, to: @me.aspects.where(name: aspect_name).first.id
end

Maxwell Salzberg's avatar
Maxwell Salzberg committed
15 16
Given /^"([^"]*)" has a public post with text "([^"]*)"$/ do |email, text|
  user = User.find_by_email(email)
Jonne Haß's avatar
Jonne Haß committed
17
  user.post(:status_message, :text => text, :public => true, :to => user.aspect_ids)
Maxwell Salzberg's avatar
Maxwell Salzberg committed
18
end
19

augier's avatar
augier committed
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
Given /^"([^"]*)" has a public post with text "([^"]*)" and a poll$/ do |email, text|
  user = User.find_by(email: email)
  post = user.post(:status_message, text: text, public: true, to: user.aspect_ids)
  FactoryGirl.create(:poll, status_message: post)
end

Given /^"([^"]*)" has a public post with text "([^"]*)" and a location$/ do |email, text|
  user = User.find_by(email: email)
  post = user.post(:status_message, text: text, public: true, to: user.aspect_ids)
  FactoryGirl.create(:location, status_message: post)
end

Given /^"([^"]*)" has a public post with text "([^"]*)" and a picture/ do |email, text|
  user = User.find_by(email: email)
  post = user.post(:status_message, text: text, public: true, to: user.aspect_ids)
35
  FactoryGirl.create(:photo, status_message: post, author: user.person)
augier's avatar
augier committed
36 37
end

38 39 40 41 42 43 44
Given /^there are (\d+) public posts from "([^"]*)"$/ do |n_posts, email|
  user = User.find_by_email(email)
  (1..n_posts.to_i).each do |n|
    user.post(:status_message, text: "post nr. #{n}", public: true, to: user.aspect_ids)
  end
end

45 46
Given /^"([^"]*)" has a non public post with text "([^"]*)"$/ do |email, text|
  user = User.find_by_email(email)
Jonne Haß's avatar
Jonne Haß committed
47
  user.post(:status_message, :text => text, :public => false, :to => user.aspect_ids)
48 49
end

50 51 52
And /^the post with text "([^"]*)" is reshared by "([^"]*)"$/ do |text, email|
  user = User.find_by_email(email)
  root = Post.find_by_text(text)
Jonne Haß's avatar
Jonne Haß committed
53
  user.post(:reshare, :root_guid => root.guid, :public => true, :to => user.aspect_ids)
54
end
55

56
When /^I click on the first block button/ do
57
  find(".stream-element", match: :first).hover
58
  find(".block_user").click
danielgrippi's avatar
danielgrippi committed
59
end
Maxwell Salzberg's avatar
Maxwell Salzberg committed
60

61 62 63 64
When /^I click on the profile block button/ do
  find("#profile_buttons .block_user").click
end

65
When /^I expand the post$/ do
66
  expand_first_post
67
end
Maxwell Salzberg's avatar
Maxwell Salzberg committed
68

Jonne Haß's avatar
Jonne Haß committed
69 70 71
When /^I open the show page of the "([^"]*)" post$/ do |post_text|
  visit post_path_by_content(post_text)
end
Asphyxia's avatar
Asphyxia committed
72

flaburgan's avatar
flaburgan committed
73 74 75 76 77 78
Then /^I should see an image attached to the post$/ do
  step %(I should see a "img" within ".stream-element div.photo-attachments")
end

Then /^I press the attached image$/ do
  step %(I press the 1st "img" within ".stream-element div.photo-attachments")
Asphyxia's avatar
Asphyxia committed
79
end