Sha256: aaa4710f39b8512c6f95e9cc5d7204ab900d01e60cc3a2b5294044d55abe8fec

Contents?: true

Size: 1.47 KB

Versions: 5

Compression:

Stored size: 1.47 KB

Contents

require "test_helper"

module Workarea
  class MailChimp::SubscriptionTest < Workarea::IntegrationTest
    setup :users

    def users
      @user ||= create_user
      @user.update_attributes(email_signup: true)
      @user
    end

    def updated_params
      @updated_params ||= { groups: [email_interests_hash] }
    end

    def test_groups_is_set_to_default_groups
      assert_equal(User.default_groups, users.groups)
    end

    def test_groups_is_not_set_to_default_groups_when_groups_are_set
      groups = [Workarea::MailChimp::Group.new(email_interests_hash)]
      users.update_attributes(groups: groups)

      assert_equal(groups, users.groups)
    end

    def test_group_updated_when_group_exists
      params = { groups: [email_interests_hash] }
      group = Workarea::MailChimp::Group.new(params[:groups].first)
      updated_group = Workarea::MailChimp::Group.new(updated_params[:groups].first)
      users.update_attributes(params)

      assert_equal(users.groups[0], group)
      users.update_attributes(updated_params)
      assert_equal(users.groups[0], updated_group)
    end

    def test_user_email_signup_true_when_email_signup_exists_with_matching_email_address
      user_email = "mailchimp-test@weblinc.com"
      Email::Signup.new(email: user_email).save

      post storefront.users_account_path,
          params: {
            email: user_email,
            password: "W3bl1nc!"
          }

      assert(User.find_by(email: user_email).email_signup?)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
workarea-mail_chimp-3.1.0 test/integration/workarea/mailchimp/subscription_test.rb
workarea-mail_chimp-3.0.5 test/integration/workarea/mailchimp/subscription_test.rb
workarea-mail_chimp-3.0.4 test/integration/workarea/mailchimp/subscription_test.rb
workarea-mail_chimp-3.0.3 test/integration/workarea/mailchimp/subscription_test.rb
workarea-mail_chimp-3.0.2 test/integration/workarea/mailchimp/subscription_test.rb